This commit is contained in:
kleponijo 2026-04-26 16:37:26 +07:00
parent c540f82761
commit 7e7af7658c
2 changed files with 5 additions and 10 deletions

View File

@ -55,7 +55,6 @@ class WindSpeedScreen extends StatelessWidget {
.map((e) => { .map((e) => {
'timestamp': e.timestamp, 'timestamp': e.timestamp,
'speed': e.speed, 'speed': e.speed,
'pulse': e.pulse,
}) })
.toList(); .toList();

View File

@ -1,26 +1,22 @@
class MyWindSpeed { class MyWindSpeed {
double speed; double speed;
int pulse;
DateTime timestamp; DateTime timestamp;
MyWindSpeed({ MyWindSpeed({required this.speed, required this.timestamp});
required this.speed,
required this.pulse,
required this.timestamp,
});
static final empty = MyWindSpeed( static final empty = MyWindSpeed(
speed: 0.0, speed: 0.0,
pulse: 0,
timestamp: DateTime.fromMillisecondsSinceEpoch(0), timestamp: DateTime.fromMillisecondsSinceEpoch(0),
); );
factory MyWindSpeed.fromJson(Map<dynamic, dynamic> json) { factory MyWindSpeed.fromJson(Map<dynamic, dynamic> json) {
return MyWindSpeed( return MyWindSpeed(
speed: (json['speed'] ?? 0).toDouble(), speed: (json['speed'] ?? 0).toDouble(),
pulse: (json['pulse'] ?? 0) as int,
timestamp: DateTime.fromMillisecondsSinceEpoch( timestamp: DateTime.fromMillisecondsSinceEpoch(
(json['timesTamp'] ?? 0) * 1000, // kalau dari Unix detik (json['timestamp'] ?? 0) * 1000, // kalau dari Unix detik
).toLocal(), ).toLocal(),
); );
} }