Fix lat/lng double decoding issue

This commit is contained in:
2026-01-19 10:54:35 +01:00
parent 9933fc90e0
commit d359970fa8

View File

@@ -70,8 +70,8 @@ class Device {
colorcode: json['colorcode'] as int?, colorcode: json['colorcode'] as int?,
status: json['status'] as int?, status: json['status'] as int?,
lastKnownMaster: json['last_known_master'] as int?, lastKnownMaster: json['last_known_master'] as int?,
lat: json['lat'] as double?, lat: _toDouble(json['lat']),
lng: json['lng'] as double?, lng: _toDouble(json['lng']),
website: json['website'] as String?, website: json['website'] as String?,
pep: json['pep'] as int?, pep: json['pep'] as int?,
agl: json['agl'] 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<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {
'id': id, 'id': id,