sos_device

This commit is contained in:
mohammad
2024-11-24 15:05:33 +03:00
parent 6733c4f4ab
commit b365f7e347
31 changed files with 3691 additions and 33 deletions

View File

@ -0,0 +1,28 @@
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,
);
}
}