mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
push living room status
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class DeviceStatus {
|
||||
final String productUuid;
|
||||
final String productType;
|
||||
final List<Status> status;
|
||||
|
||||
DeviceStatus({
|
||||
required this.productUuid,
|
||||
required this.productType,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory DeviceStatus.fromMap(Map<String, dynamic> map) {
|
||||
return DeviceStatus(
|
||||
productUuid: map['productUuid'] ?? '',
|
||||
productType: map['productType'] ?? '',
|
||||
status: List<Status>.from(
|
||||
map['status']?.map((x) => Status.fromMap(x)) ?? const []),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'productUuid': productUuid,
|
||||
'productType': productType,
|
||||
'status': status.map((x) => x.toMap()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
factory DeviceStatus.fromJson(Map<String, dynamic> json) =>
|
||||
DeviceStatus.fromMap(json);
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
||||
|
||||
class Status {
|
||||
final String code;
|
||||
final dynamic value;
|
||||
|
||||
Status({
|
||||
required this.code,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
factory Status.fromMap(Map<String, dynamic> map) {
|
||||
return Status(
|
||||
code: map['code'] ?? '',
|
||||
value: map['value'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'code': code,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
|
||||
factory Status.fromJson(String source) => Status.fromMap(json.decode(source));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
Reference in New Issue
Block a user