mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
29 lines
746 B
Dart
29 lines
746 B
Dart
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
|
|
|
class SosModel {
|
|
String sosContactState;
|
|
int batteryPercentage;
|
|
|
|
SosModel({
|
|
required this.sosContactState,
|
|
required this.batteryPercentage,
|
|
});
|
|
|
|
factory SosModel.fromJson(List<StatusModel> jsonList) {
|
|
late String _sosContactState;
|
|
late int _batteryPercentage;
|
|
|
|
for (int i = 0; i < jsonList.length; i++) {
|
|
if (jsonList[i].code == 'sos') {
|
|
_sosContactState = jsonList[i].value ?? '';
|
|
} else if (jsonList[i].code == 'battery_percentage') {
|
|
_batteryPercentage = jsonList[i].value ?? 0;
|
|
}
|
|
}
|
|
return SosModel(
|
|
sosContactState: _sosContactState,
|
|
batteryPercentage: _batteryPercentage,
|
|
);
|
|
}
|
|
}
|