import 'package:syncrow_app/features/devices/model/status_model.dart'; class TwoGangModel { bool firstSwitch; bool secondSwitch; int firstCountDown; int secondCountDown; TwoGangModel( {required this.firstSwitch, required this.secondSwitch, required this.firstCountDown, required this.secondCountDown, }); factory TwoGangModel.fromJson(List jsonList) { late bool _firstSwitch; late bool _secondSwitch; late int _firstCount; late int _secondCount; for (int i = 0; i < jsonList.length; i++) { if (jsonList[i].code == 'switch_1') { _firstSwitch = jsonList[i].value ?? false; } else if (jsonList[i].code == 'switch_2') { _secondSwitch = jsonList[i].value ?? false; }else if (jsonList[i].code == 'countdown_1') { _firstCount = jsonList[i].value ?? 0; } else if (jsonList[i].code == 'countdown_2') { _secondCount = jsonList[i].value ?? 0; } } return TwoGangModel( firstSwitch: _firstSwitch, secondSwitch: _secondSwitch, firstCountDown: _firstCount, secondCountDown: _secondCount, ); } }