Files
syncrow-app/lib/features/devices/model/sos_model.dart
2024-11-24 15:05:33 +03:00

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,
);
}
}