fix: show empty time instead of 1970 when timestamp is 0

This commit is contained in:
fiatcode 2026-05-02 17:34:39 +07:00
parent 8884bdcb40
commit 27d2841081
No known key found for this signature in database

View file

@ -63,7 +63,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
_lastSpeed = (speed * 3.6).toStringAsFixed(1); _lastSpeed = (speed * 3.6).toStringAsFixed(1);
} }
final timestamp = status?['lastTimestamp']; final timestamp = status?['lastTimestamp'];
if (timestamp != null) { if (timestamp != null && timestamp > 0) {
_lastTime = _formatDateTime( _lastTime = _formatDateTime(
DateTime.fromMillisecondsSinceEpoch(timestamp), DateTime.fromMillisecondsSinceEpoch(timestamp),
); );
@ -79,7 +79,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
_lastSpeed = location['speed'] != null _lastSpeed = location['speed'] != null
? (location['speed'] * 3.6).toStringAsFixed(1) ? (location['speed'] * 3.6).toStringAsFixed(1)
: '--'; : '--';
_lastTime = location['timestamp'] != null _lastTime = location['timestamp'] != null && location['timestamp'] > 0
? _formatDateTime( ? _formatDateTime(
DateTime.fromMillisecondsSinceEpoch(location['timestamp']), DateTime.fromMillisecondsSinceEpoch(location['timestamp']),
) )