mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
Refactor HTTPInterceptor and add CustomSnackBar helper
Refactor HTTPInterceptor to handle error responses and add a CustomSnackBar helper to display snack bars. This will improve error handling and user feedback in the application.
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@ -42,6 +41,14 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_instance = null;
|
||||
selectedSpace = null;
|
||||
selectedRoom = null;
|
||||
return super.close();
|
||||
}
|
||||
|
||||
static HomeCubit get(context) => BlocProvider.of(context);
|
||||
|
||||
List<SpaceModel>? spaces;
|
||||
@ -124,8 +131,8 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
selectedSpace = spaces!.first
|
||||
: null;
|
||||
emitSafe(GetSpacesLoaded(spaces!));
|
||||
} on DioException catch (e) {
|
||||
emitSafe(GetSpacesError(ServerFailure.fromDioError(e).errMessage));
|
||||
} on ServerFailure catch (failure) {
|
||||
emitSafe(GetSpacesError(failure.errMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,17 +145,13 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
} else {
|
||||
emitSafe(GetSpaceRoomsError("No rooms found"));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
emitSafe(GetSpacesError(ServerFailure.fromDioError(e).errMessage));
|
||||
} on ServerFailure catch (failure) {
|
||||
emitSafe(GetSpacesError(failure.errMessage));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////// Nav ///////////////////////////////////////
|
||||
|
||||
static clear() {
|
||||
pageIndex = 0;
|
||||
}
|
||||
|
||||
static int pageIndex = 0;
|
||||
|
||||
static Map<String, List<Widget>> appBarActions = {
|
||||
|
Reference in New Issue
Block a user