diff --git a/lib/features/devices/bloc/devices_cubit.dart b/lib/features/devices/bloc/devices_cubit.dart index 2f3c7e1..cebe17e 100644 --- a/lib/features/devices/bloc/devices_cubit.dart +++ b/lib/features/devices/bloc/devices_cubit.dart @@ -24,6 +24,13 @@ class DevicesCubit extends Cubit { DevicesCubit() : super(DevicesInitial()) { fetchGroups(SpacesCubit.selectedSpace!.id!); } + bool _isClosed = false; + + @override + Future close() { + _isClosed = true; + return super.close(); + } static DevicesCubit get(context) => BlocProvider.of(context); @@ -229,6 +236,8 @@ class DevicesCubit extends Cubit { } fetchGroups(int spaceId) async { + if (_isClosed) return; + try { emit(DevicesCategoriesLoading()); allCategories = await DevicesAPI.fetchGroups(spaceId);