fix selection for the devices

This commit is contained in:
ashrafzarkanisala
2024-08-27 18:49:59 +03:00
parent 56edcaf788
commit 76b3b6a432
6 changed files with 71 additions and 64 deletions

View File

@ -34,7 +34,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
FutureOr<void> _onAcControl(AcControl event, Emitter<AcsState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
_updateLocalValue(event.code, event.value, emit);
emit(ACStatusLoaded(deviceStatus));
@ -75,12 +75,12 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
void _revertValueAndEmit(
String deviceId, String code, dynamic oldValue, Emitter<AcsState> emit) {
_updateLocalValue(code, oldValue);
_updateLocalValue(code, oldValue, emit);
emit(ACStatusLoaded(deviceStatus));
emit(const AcsFailedState(error: 'Failed to control the device.'));
}
void _updateLocalValue(String code, dynamic value) {
void _updateLocalValue(String code, dynamic value, Emitter<AcsState> emit) {
switch (code) {
case 'switch':
if (value is bool) {