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) => {
'timestamp': e.timestamp,
'speed': e.speed,
'pulse': e.pulse,
})
.toList();

View File

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