set default values in the devices models instead of late, and fixed issues in the AC bloc

This commit is contained in:
Abdullah Alassaf
2025-02-20 04:13:37 +03:00
parent 3f7f7ce49f
commit 450b773921
14 changed files with 106 additions and 148 deletions

View File

@ -4,7 +4,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart'; import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.dart'; import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/ac_model.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart'; import 'package:syncrow_app/features/devices/model/device_control_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart';
@ -28,7 +27,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
bool allAcsPage = false; bool allAcsPage = false;
bool allAcsOn = true; bool allAcsOn = true;
bool allTempSame = true; bool allTempSame = true;
int globalTemp = 25; int globalTemp = 250;
Timer? _timer; Timer? _timer;
ACsBloc({required this.acId}) : super(AcsInitialState()) { ACsBloc({required this.acId}) : super(AcsInitialState()) {
@ -69,8 +68,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
for (var status in response['status']) { for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status)); statusModelList.add(StatusModel.fromJson(status));
} }
deviceStatus = deviceStatus = AcStatusModel.fromJson(response['productUuid'], statusModelList);
AcStatusModel.fromJson(response['productUuid'], statusModelList);
emit(GetAcStatusState(acStatusModel: deviceStatus)); emit(GetAcStatusState(acStatusModel: deviceStatus));
Future.delayed(const Duration(milliseconds: 500)); Future.delayed(const Duration(milliseconds: 500));
// _listenToChanges(); // _listenToChanges();
@ -83,22 +81,18 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
_listenToChanges() { _listenToChanges() {
try { try {
DatabaseReference ref = DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$acId');
FirebaseDatabase.instance.ref('device-status/$acId');
Stream<DatabaseEvent> stream = ref.onValue; Stream<DatabaseEvent> stream = ref.onValue;
stream.listen((DatabaseEvent event) { stream.listen((DatabaseEvent event) {
Map<dynamic, dynamic> usersMap = Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
event.snapshot.value as Map<dynamic, dynamic>;
List<StatusModel> statusList = []; List<StatusModel> statusList = [];
usersMap['status'].forEach((element) { usersMap['status'].forEach((element) {
statusList statusList.add(StatusModel(code: element['code'], value: element['value']));
.add(StatusModel(code: element['code'], value: element['value']));
}); });
deviceStatus = deviceStatus = AcStatusModel.fromJson(usersMap['productUuid'], statusList);
AcStatusModel.fromJson(usersMap['productUuid'], statusList);
add(AcUpdated()); add(AcUpdated());
}); });
} catch (_) {} } catch (_) {}
@ -115,14 +109,12 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
HomeCubit.getInstance().selectedSpace?.id ?? '', 'AC'); HomeCubit.getInstance().selectedSpace?.id ?? '', 'AC');
for (int i = 0; i < devicesList.length; i++) { for (int i = 0; i < devicesList.length; i++) {
var response = var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
List<StatusModel> statusModelList = []; List<StatusModel> statusModelList = [];
for (var status in response['status']) { for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status)); statusModelList.add(StatusModel.fromJson(status));
} }
deviceStatusList.add( deviceStatusList.add(AcStatusModel.fromJson(devicesList[i].uuid ?? '', statusModelList));
AcStatusModel.fromJson(response['productUuid'], statusModelList));
} }
_setAllAcsTempsAndSwitches(); _setAllAcsTempsAndSwitches();
} }
@ -132,7 +124,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
if (allAcsPage) { if (allAcsPage) {
emit(AcsLoadingState()); emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) { for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) { if (ac.uuid == event.deviceId) {
ac.acSwitch = acSwitchValue; ac.acSwitch = acSwitchValue;
} }
} }
@ -145,8 +137,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
emit(AcModifyingState(acStatusModel: deviceStatus)); emit(AcModifyingState(acStatusModel: deviceStatus));
} }
await _runDeBouncerForOneDevice( await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'switch', value: acSwitchValue);
deviceId: event.deviceId, code: 'switch', value: acSwitchValue);
} }
void _changeAllAcSwitch(ChangeAllSwitch event, Emitter<AcsState> emit) async { void _changeAllAcSwitch(ChangeAllSwitch event, Emitter<AcsState> emit) async {
@ -207,8 +198,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
deviceStatus.childLock = lockValue; deviceStatus.childLock = lockValue;
emit(AcModifyingState(acStatusModel: deviceStatus)); emit(AcModifyingState(acStatusModel: deviceStatus));
await _runDeBouncerForOneDevice( await _runDeBouncerForOneDevice(deviceId: acId, code: 'child_lock', value: lockValue);
deviceId: acId, code: 'child_lock', value: lockValue);
} }
void _increaseCoolTo(IncreaseCoolToTemp event, Emitter<AcsState> emit) async { void _increaseCoolTo(IncreaseCoolToTemp event, Emitter<AcsState> emit) async {
@ -224,7 +214,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
if (allAcsPage) { if (allAcsPage) {
emit(AcsLoadingState()); emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) { for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) { if (ac.uuid == event.deviceId) {
ac.tempSet = value; ac.tempSet = value;
} }
} }
@ -236,8 +226,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
emit(AcModifyingState(acStatusModel: deviceStatus)); emit(AcModifyingState(acStatusModel: deviceStatus));
} }
await _runDeBouncerForOneDevice( await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'temp_set', value: value);
deviceId: event.deviceId, code: 'temp_set', value: value);
} }
void _decreaseCoolTo(DecreaseCoolToTemp event, Emitter<AcsState> emit) async { void _decreaseCoolTo(DecreaseCoolToTemp event, Emitter<AcsState> emit) async {
@ -253,7 +242,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
if (allAcsPage) { if (allAcsPage) {
emit(AcsLoadingState()); emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) { for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) { if (ac.uuid == event.deviceId) {
ac.tempSet = value; ac.tempSet = value;
} }
} }
@ -265,8 +254,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
emit(AcModifyingState(acStatusModel: deviceStatus)); emit(AcModifyingState(acStatusModel: deviceStatus));
} }
await _runDeBouncerForOneDevice( await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'temp_set', value: value);
deviceId: event.deviceId, code: 'temp_set', value: value);
} }
void _changeAcMode(ChangeAcMode event, Emitter<AcsState> emit) async { void _changeAcMode(ChangeAcMode event, Emitter<AcsState> emit) async {
@ -274,7 +262,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
if (allAcsPage) { if (allAcsPage) {
emit(AcsLoadingState()); emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) { for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) { if (ac.uuid == event.deviceId) {
ac.modeString = getACModeString(tempMode); ac.modeString = getACModeString(tempMode);
ac.acMode = AcStatusModel.getACMode(getACModeString(tempMode)); ac.acMode = AcStatusModel.getACMode(getACModeString(tempMode));
} }
@ -288,9 +276,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
} }
await _runDeBouncerForOneDevice( await _runDeBouncerForOneDevice(
deviceId: event.deviceId, deviceId: event.deviceId, code: 'mode', value: getACModeString(tempMode));
code: 'mode',
value: getACModeString(tempMode));
} }
void _changeFanSpeed(ChangeFanSpeed event, Emitter<AcsState> emit) async { void _changeFanSpeed(ChangeFanSpeed event, Emitter<AcsState> emit) async {
@ -301,25 +287,21 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
if (allAcsPage) { if (allAcsPage) {
emit(AcsLoadingState()); emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) { for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) { if (ac.uuid == event.deviceId) {
ac.fanSpeedsString = getNextFanSpeedKey(fanSpeed); ac.fanSpeedsString = getNextFanSpeedKey(fanSpeed);
ac.acFanSpeed = ac.acFanSpeed = AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
} }
} }
_emitAcsStatus(emit); _emitAcsStatus(emit);
} else { } else {
emit(AcChangeLoading(acStatusModel: deviceStatus)); emit(AcChangeLoading(acStatusModel: deviceStatus));
deviceStatus.fanSpeedsString = getNextFanSpeedKey(fanSpeed); deviceStatus.fanSpeedsString = getNextFanSpeedKey(fanSpeed);
deviceStatus.acFanSpeed = deviceStatus.acFanSpeed = AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
emit(AcModifyingState(acStatusModel: deviceStatus)); emit(AcModifyingState(acStatusModel: deviceStatus));
} }
await _runDeBouncerForOneDevice( await _runDeBouncerForOneDevice(
deviceId: event.deviceId, deviceId: event.deviceId, code: 'level', value: getNextFanSpeedKey(fanSpeed));
code: 'level',
value: getNextFanSpeedKey(fanSpeed));
} }
String getACModeString(TempModes value) { String getACModeString(TempModes value) {
@ -338,17 +320,15 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
allAcsOn = true; allAcsOn = true;
allTempSame = true; allTempSame = true;
if (deviceStatusList.isNotEmpty) { if (deviceStatusList.isNotEmpty) {
int temp = deviceStatusList[0].tempSet; int temp = deviceStatusList.first.tempSet;
deviceStatusList.firstWhere((element) { for (var element in deviceStatusList) {
if (!element.acSwitch) { if (!element.acSwitch) {
allAcsOn = false; allAcsOn = false;
} }
if (element.tempSet != temp) { if (element.tempSet != temp) {
allTempSame = false; allTempSame = false;
} }
}
return true;
});
if (allTempSame) { if (allTempSame) {
globalTemp = temp; globalTemp = temp;
} }
@ -364,8 +344,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
for (int i = 0; i < deviceStatusList.length; i++) { for (int i = 0; i < deviceStatusList.length; i++) {
try { try {
await DevicesAPI.controlDevice( await DevicesAPI.controlDevice(
DeviceControlModel( DeviceControlModel(deviceId: devicesList[i].uuid, code: code, value: value),
deviceId: devicesList[i].uuid, code: code, value: value),
devicesList[i].uuid ?? ''); devicesList[i].uuid ?? '');
} catch (_) { } catch (_) {
await Future.delayed(const Duration(milliseconds: 500)); await Future.delayed(const Duration(milliseconds: 500));
@ -387,10 +366,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
_timer = Timer(const Duration(seconds: 1), () async { _timer = Timer(const Duration(seconds: 1), () async {
try { try {
final response = await DevicesAPI.controlDevice( final response = await DevicesAPI.controlDevice(
DeviceControlModel( DeviceControlModel(deviceId: allAcsPage ? deviceId : acId, code: code, value: value),
deviceId: allAcsPage ? deviceId : acId,
code: code,
value: value),
allAcsPage ? deviceId : acId); allAcsPage ? deviceId : acId);
if (!response['success']) { if (!response['success']) {
@ -407,8 +383,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
if (value >= 20 && value <= 30) { if (value >= 20 && value <= 30) {
return true; return true;
} else { } else {
emit(const AcsFailedState( emit(const AcsFailedState(errorMessage: 'The temperature must be between 20 and 30'));
errorMessage: 'The temperature must be between 20 and 30'));
emit(GetAllAcsStatusState( emit(GetAllAcsStatusState(
allAcsStatues: deviceStatusList, allAcsStatues: deviceStatusList,
allAcs: devicesList, allAcs: devicesList,
@ -434,9 +409,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
try { try {
seconds = event.seconds; seconds = event.seconds;
final response = await DevicesAPI.controlDevice( final response = await DevicesAPI.controlDevice(
DeviceControlModel( DeviceControlModel(deviceId: acId, code: 'countdown_time', value: event.duration), acId);
deviceId: acId, code: 'countdown_time', value: event.duration),
acId);
if (response['success'] ?? false) { if (response['success'] ?? false) {
deviceStatus.countdown1 = seconds; deviceStatus.countdown1 = seconds;
@ -463,8 +436,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
for (var status in response['status']) { for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status)); statusModelList.add(StatusModel.fromJson(status));
} }
deviceStatus = deviceStatus = AcStatusModel.fromJson(response['productUuid'], statusModelList);
AcStatusModel.fromJson(response['productUuid'], statusModelList);
deviceStatus.countdown1; deviceStatus.countdown1;
var duration; var duration;
if (deviceStatus.countdown1 == 5) { if (deviceStatus.countdown1 == 5) {

View File

@ -27,24 +27,24 @@ class AcStatusModel {
} }
factory AcStatusModel.fromJson(String id, List<StatusModel> jsonList) { factory AcStatusModel.fromJson(String id, List<StatusModel> jsonList) {
late bool _acSwitch; bool _acSwitch = false;
late String _mode; String _mode = '';
late int _tempSet; int _tempSet = 210;
late int _currentTemp; int _currentTemp = 210;
late String _fanSpeeds; String _fanSpeeds = '';
late int _countdown1; int _countdown1 = 0;
late bool _childLock; bool _childLock = false;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'switch') { if (jsonList[i].code == 'switch') {
_acSwitch = jsonList[i].value ?? false; _acSwitch = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'mode') { } else if (jsonList[i].code == 'mode') {
_mode = jsonList[i].value ?? TempModes.cold; _mode = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'temp_set') { } else if (jsonList[i].code == 'temp_set') {
_tempSet = jsonList[i].value ?? 210; _tempSet = jsonList[i].value ?? 210;
} else if (jsonList[i].code == 'temp_current') { } else if (jsonList[i].code == 'temp_current') {
_currentTemp = jsonList[i].value ?? 210; _currentTemp = jsonList[i].value ?? 210;
} else if (jsonList[i].code == 'level') { } else if (jsonList[i].code == 'level') {
_fanSpeeds = jsonList[i].value ?? 210; _fanSpeeds = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'child_lock') { } else if (jsonList[i].code == 'child_lock') {
_childLock = jsonList[i].value ?? false; _childLock = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'countdown_time') { } else if (jsonList[i].code == 'countdown_time') {

View File

@ -23,9 +23,9 @@ class CeilingSensorModel {
required this.bodyMovement}); required this.bodyMovement});
factory CeilingSensorModel.fromJson(List<StatusModel> jsonList) { factory CeilingSensorModel.fromJson(List<StatusModel> jsonList) {
late String _presenceState; String _presenceState = 'none';
late int _sensitivity; int _sensitivity = 1;
late String _checkingResult; String _checkingResult = '';
int _presenceRange = 1; int _presenceRange = 1;
int _sportsPara = 1; int _sportsPara = 1;
int _moving_max_dis = 0; int _moving_max_dis = 0;

View File

@ -10,11 +10,11 @@ class CurtainModel {
}); });
factory CurtainModel.fromJson(List<StatusModel> jsonList) { factory CurtainModel.fromJson(List<StatusModel> jsonList) {
late String _control; String _control = '';
late int _percent; int _percent = 0;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'control') { if (jsonList[i].code == 'control') {
_control = jsonList[i].value ?? false; _control = jsonList[i].value ?? '';
} }
if (jsonList[i].code == 'percent_control') { if (jsonList[i].code == 'percent_control') {
_percent = jsonList[i].value ?? 0; _percent = jsonList[i].value ?? 0;

View File

@ -1,5 +1,3 @@
import 'dart:convert';
class DeviceInfoModel { class DeviceInfoModel {
final int activeTime; final int activeTime;
final String category; final String category;

View File

@ -1,22 +1,17 @@
import 'package:syncrow_app/features/devices/model/status_model.dart'; import 'package:syncrow_app/features/devices/model/status_model.dart';
class DoorSensorModel { class DoorSensorModel {
bool doorContactState; bool doorContactState;
int batteryPercentage; int batteryPercentage;
DoorSensorModel( DoorSensorModel({
{required this.doorContactState, required this.doorContactState,
required this.batteryPercentage, required this.batteryPercentage,
}); });
factory DoorSensorModel.fromJson(List<StatusModel> jsonList) { factory DoorSensorModel.fromJson(List<StatusModel> jsonList) {
late bool _doorContactState; bool _doorContactState = false;
late int _batteryPercentage; int _batteryPercentage = 0;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'doorcontact_state') { if (jsonList[i].code == 'doorcontact_state') {

View File

@ -24,15 +24,15 @@ class GarageDoorModel {
}); });
factory GarageDoorModel.fromJson(List<StatusModel> jsonList) { factory GarageDoorModel.fromJson(List<StatusModel> jsonList) {
late bool _switch1 = false; bool _switch1 = false;
late bool _doorContactState = false; bool _doorContactState = false;
late int _countdown1 = 0; int _countdown1 = 0;
late int _countdownAlarm = 0; int _countdownAlarm = 0;
late String _doorControl1 = "closed"; String _doorControl1 = "closed";
late bool _voiceControl1 = false; bool _voiceControl1 = false;
late String _doorState1 = "closed"; String _doorState1 = "closed";
late int _batteryPercentage = 0; int _batteryPercentage = 0;
late int _tr_timecon = 0; int _tr_timecon = 0;
for (var status in jsonList) { for (var status in jsonList) {
switch (status.code) { switch (status.code) {

View File

@ -1,19 +1,17 @@
import 'package:syncrow_app/features/devices/model/status_model.dart'; import 'package:syncrow_app/features/devices/model/status_model.dart';
class OneGangModel { class OneGangModel {
bool firstSwitch; bool firstSwitch;
int firstCountDown; int firstCountDown;
OneGangModel( OneGangModel({
{required this.firstSwitch, required this.firstSwitch,
required this.firstCountDown, required this.firstCountDown,
}); });
factory OneGangModel.fromJson(List<StatusModel> jsonList) { factory OneGangModel.fromJson(List<StatusModel> jsonList) {
late bool _switch; bool _switch = false;
late int _count; int _count = 0;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'switch_1') { if (jsonList[i].code == 'switch_1') {

View File

@ -1,5 +1,3 @@
import 'package:syncrow_app/features/devices/model/status_model.dart'; import 'package:syncrow_app/features/devices/model/status_model.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart';
@ -15,15 +13,14 @@ class OneTouchModel {
required this.firstCountDown, required this.firstCountDown,
required this.light_mode, required this.light_mode,
required this.relay, required this.relay,
required this.relay_status_1 required this.relay_status_1});
});
factory OneTouchModel.fromJson(List<StatusModel> jsonList) { factory OneTouchModel.fromJson(List<StatusModel> jsonList) {
late bool _switch; bool _switch = false;
late int _count; int _count = 0;
late String _relay; String _relay = '';
late String _light_mode; String _light_mode = '';
late String relay_status_1; String relay_status_1 = '';
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'switch_1') { if (jsonList[i].code == 'switch_1') {
@ -41,10 +38,8 @@ class OneTouchModel {
return OneTouchModel( return OneTouchModel(
firstSwitch: _switch, firstSwitch: _switch,
firstCountDown: _count, firstCountDown: _count,
light_mode: lightStatusExtension.fromString(_light_mode) , light_mode: lightStatusExtension.fromString(_light_mode),
relay: StatusExtension.fromString(_relay ) , relay: StatusExtension.fromString(_relay),
relay_status_1: StatusExtension.fromString(relay_status_1 ) relay_status_1: StatusExtension.fromString(relay_status_1));
);
} }
} }

View File

@ -22,14 +22,14 @@ class SixSceneModel {
}); });
factory SixSceneModel.fromJson(List<StatusModel> jsonList) { factory SixSceneModel.fromJson(List<StatusModel> jsonList) {
late dynamic _scene_1; dynamic _scene_1 = '';
late dynamic _scene_2; dynamic _scene_2 = '';
late dynamic _scene_3; dynamic _scene_3 = '';
late dynamic _scene_4; dynamic _scene_4 = '';
late dynamic _scene_5; dynamic _scene_5 = '';
late dynamic _scene_6; dynamic _scene_6 = '';
late dynamic _scene_id_group_id; dynamic _scene_id_group_id = 0;
late dynamic _switch_backlight; dynamic _switch_backlight = false;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'scene_1') { if (jsonList[i].code == 'scene_1') {

View File

@ -39,23 +39,23 @@ class SmartDoorModel {
required this.normalOpenSwitch}); required this.normalOpenSwitch});
factory SmartDoorModel.fromJson(List<StatusModel> jsonList) { factory SmartDoorModel.fromJson(List<StatusModel> jsonList) {
late int _unlockFingerprint; int _unlockFingerprint = 0;
late int _unlockPassword; int _unlockPassword = 0;
late int _unlockTemporary; int _unlockTemporary = 0;
late int _unlockCard; int _unlockCard = 0;
late String _unlockAlarm; String _unlockAlarm = '';
late int _unlockRequest; int _unlockRequest = 0;
late int _residualElectricity; int _residualElectricity = 0;
late bool _reverseLock; bool _reverseLock = false;
late int _unlockApp; int _unlockApp = 0;
late bool _hijack; bool _hijack = false;
late bool _doorbell; bool _doorbell = false;
late String _unlockOfflinePd; String _unlockOfflinePd = '';
late String _unlockOfflineClear; String _unlockOfflineClear = '';
late String _unlockDoubleKit; String _unlockDoubleKit = '';
late String _remoteNoPdSetkey; String _remoteNoPdSetkey = '';
late String _remoteNoDpKey; String _remoteNoDpKey = '';
late bool _normalOpenSwitch; bool _normalOpenSwitch = false;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'unlock_fingerprint') { if (jsonList[i].code == 'unlock_fingerprint') {

View File

@ -10,8 +10,8 @@ class SosModel {
}); });
factory SosModel.fromJson(List<StatusModel> jsonList) { factory SosModel.fromJson(List<StatusModel> jsonList) {
late String _sosContactState; String _sosContactState = '';
late int _batteryPercentage; int _batteryPercentage = 0;
for (int i = 0; i < jsonList.length; i++) { for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'sos') { if (jsonList[i].code == 'sos') {

View File

@ -31,7 +31,7 @@ class ACsList extends StatelessWidget {
List<DeviceModel> devicesList = []; List<DeviceModel> devicesList = [];
bool allOn = false; bool allOn = false;
bool allTempSame = false; bool allTempSame = false;
int temperature = 20; int temperature = 250;
if (state is GetAllAcsStatusState) { if (state is GetAllAcsStatusState) {
devicesStatuesList = state.allAcsStatues; devicesStatuesList = state.allAcsStatues;
devicesList = state.allAcs; devicesList = state.allAcs;

View File

@ -5,7 +5,7 @@ description: This is the mobile application project, developed with Flutter for
# pub.dev using `flutter pub publish`. This is preferred for private packages. # pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.18+55 version: 1.0.27+64
environment: environment:
sdk: ">=3.0.6 <4.0.0" sdk: ">=3.0.6 <4.0.0"