mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 01:35:23 +00:00

Added try-catch blocks for error handling in API's files to rethrow the errors to the cubit so cubits can update the UI based on them. Refactored error handling in HTTPInterceptor and HTTPService classes.
61 lines
1.1 KiB
Dart
61 lines
1.1 KiB
Dart
part of 'home_cubit.dart';
|
|
|
|
abstract class HomeState {}
|
|
|
|
class HomeInitial extends HomeState {}
|
|
|
|
//base states
|
|
class HomeLoading extends HomeState {}
|
|
|
|
class HomeError extends HomeState {
|
|
final String errMessage;
|
|
|
|
HomeError(this.errMessage);
|
|
}
|
|
|
|
class HomeSuccess extends HomeState {}
|
|
|
|
///specific states
|
|
//get spaces
|
|
class GetSpacesLoading extends HomeLoading {}
|
|
|
|
class GetSpacesSuccess extends HomeSuccess {
|
|
final List<SpaceModel> spaces;
|
|
|
|
GetSpacesSuccess(this.spaces);
|
|
}
|
|
|
|
class GetSpacesError extends HomeError {
|
|
GetSpacesError(super.errMessage);
|
|
}
|
|
|
|
//get rooms
|
|
class GetSpaceRoomsLoading extends HomeLoading {}
|
|
|
|
class GetSpaceRoomsSuccess extends HomeSuccess {
|
|
final List<RoomModel> rooms;
|
|
|
|
GetSpaceRoomsSuccess(this.rooms);
|
|
}
|
|
|
|
class GetSpaceRoomsError extends HomeError {
|
|
GetSpaceRoomsError(super.errMessage);
|
|
}
|
|
|
|
//UI states
|
|
class SpaceSelected extends HomeState {
|
|
final SpaceModel space;
|
|
|
|
SpaceSelected(this.space);
|
|
}
|
|
|
|
class RoomSelected extends HomeState {
|
|
final RoomModel room;
|
|
|
|
RoomSelected(this.room);
|
|
}
|
|
|
|
class RoomUnSelected extends HomeState {}
|
|
|
|
class NavChangePage extends HomeState {}
|