mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 08:07:56 +00:00
Add close method override in DevicesCubit
Add override for close method in DevicesCubit to set _isClosed flag and call super.close(). This prevents further operations after closing.
This commit is contained in:
@@ -24,6 +24,13 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
DevicesCubit() : super(DevicesInitial()) {
|
||||
fetchGroups(SpacesCubit.selectedSpace!.id!);
|
||||
}
|
||||
bool _isClosed = false;
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_isClosed = true;
|
||||
return super.close();
|
||||
}
|
||||
|
||||
static DevicesCubit get(context) => BlocProvider.of(context);
|
||||
|
||||
@@ -229,6 +236,8 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
}
|
||||
|
||||
fetchGroups(int spaceId) async {
|
||||
if (_isClosed) return;
|
||||
|
||||
try {
|
||||
emit(DevicesCategoriesLoading());
|
||||
allCategories = await DevicesAPI.fetchGroups(spaceId);
|
||||
|
||||
Reference in New Issue
Block a user