fix: show -- instead of 0.0 when speed is 0 or null

This commit is contained in:
fiatcode 2026-05-02 17:36:42 +07:00
parent 27d2841081
commit 1319167165
No known key found for this signature in database

View file

@ -59,7 +59,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
_lastLon = lon.toStringAsFixed(5); _lastLon = lon.toStringAsFixed(5);
} }
final speed = status?['lastSpeed']; final speed = status?['lastSpeed'];
if (speed != null) { if (speed != null && speed > 0) {
_lastSpeed = (speed * 3.6).toStringAsFixed(1); _lastSpeed = (speed * 3.6).toStringAsFixed(1);
} }
final timestamp = status?['lastTimestamp']; final timestamp = status?['lastTimestamp'];
@ -76,7 +76,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
setState(() { setState(() {
_lastLat = location['latitude']?.toStringAsFixed(5) ?? '--'; _lastLat = location['latitude']?.toStringAsFixed(5) ?? '--';
_lastLon = location['longitude']?.toStringAsFixed(5) ?? '--'; _lastLon = location['longitude']?.toStringAsFixed(5) ?? '--';
_lastSpeed = location['speed'] != null _lastSpeed = location['speed'] != null && location['speed'] > 0
? (location['speed'] * 3.6).toStringAsFixed(1) ? (location['speed'] * 3.6).toStringAsFixed(1)
: '--'; : '--';
_lastTime = location['timestamp'] != null && location['timestamp'] > 0 _lastTime = location['timestamp'] != null && location['timestamp'] > 0