From d359970fa837c0bdf83885cec51ca42b0a4a0304 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Mon, 19 Jan 2026 10:54:35 +0100 Subject: [PATCH] Fix lat/lng double decoding issue --- lib/models/device.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/models/device.dart b/lib/models/device.dart index 735822c..2bd48e8 100644 --- a/lib/models/device.dart +++ b/lib/models/device.dart @@ -70,8 +70,8 @@ class Device { colorcode: json['colorcode'] as int?, status: json['status'] as int?, lastKnownMaster: json['last_known_master'] as int?, - lat: json['lat'] as double?, - lng: json['lng'] as double?, + lat: _toDouble(json['lat']), + lng: _toDouble(json['lng']), website: json['website'] as String?, pep: json['pep'] as int?, agl: json['agl'] as int?, @@ -85,6 +85,14 @@ class Device { ); } + static double? _toDouble(dynamic value) { + if (value == null) return null; + if (value is double) return value; + if (value is int) return value.toDouble(); + if (value is String) return double.tryParse(value); + return null; + } + Map toJson() { return { 'id': id,