Bottle.dart
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Bottle {
final int bottleId;
final int temperature;
final int humidity;
final int balance;
final DateTime recentOpen;
final int medicineId;
final int hubId;
final int dosage;
Bottle(
{this.bottleId,
this.temperature,
this.humidity,
this.balance,
this.recentOpen,
this.medicineId,
this.hubId,
this.dosage});
factory Bottle.fromJson(Map<String, dynamic> parsedJson) {
return Bottle(
bottleId: parsedJson['bottleId'],
temperature: parsedJson['temperature'],
humidity: parsedJson['humidity'],
balance: parsedJson['balance'],
recentOpen: DateTime.parse(parsedJson['recentOpen']),
medicineId: parsedJson['medicineId'],
hubId: parsedJson['hubId'],
dosage: parsedJson['dosage'],
);
}
Map<String, dynamic> toJson() => {
"bottleId": bottleId,
"temperature": temperature,
"humidity:": humidity,
"balance": balance,
"recentOpen": recentOpen,
"medicineId": medicineId,
"hubId": hubId,
"dosage": dosage,
};
}