mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Created GatewayModel
.
This commit is contained in:
40
lib/pages/device_managment/gateway/model/gateway_model.dart
Normal file
40
lib/pages/device_managment/gateway/model/gateway_model.dart
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
class GatewayModel {
|
||||||
|
final String uuid;
|
||||||
|
final bool switchAlarmSound;
|
||||||
|
final String masterState;
|
||||||
|
final bool factoryReset;
|
||||||
|
final String alarmActive;
|
||||||
|
|
||||||
|
GatewayModel({
|
||||||
|
required this.uuid,
|
||||||
|
required this.switchAlarmSound,
|
||||||
|
required this.masterState,
|
||||||
|
required this.factoryReset,
|
||||||
|
required this.alarmActive,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory GatewayModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
final status = json['status'] as List<dynamic>;
|
||||||
|
|
||||||
|
final switchAlarmSound = status.firstWhere(
|
||||||
|
(item) => item['code'] == 'switch_alarm_sound',
|
||||||
|
)['value'] as bool;
|
||||||
|
final masterState = status.firstWhere(
|
||||||
|
(item) => item['code'] == 'master_state',
|
||||||
|
)['value'] as String;
|
||||||
|
final factoryReset = status.firstWhere(
|
||||||
|
(item) => item['code'] == 'factory_reset',
|
||||||
|
)['value'] as bool;
|
||||||
|
final alarmActive = status.firstWhere(
|
||||||
|
(item) => item['code'] == 'alarm_active',
|
||||||
|
)['value'] as String;
|
||||||
|
|
||||||
|
return GatewayModel(
|
||||||
|
uuid: json['uuid'] as String,
|
||||||
|
switchAlarmSound: switchAlarmSound,
|
||||||
|
masterState: masterState,
|
||||||
|
factoryReset: factoryReset,
|
||||||
|
alarmActive: alarmActive,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user