api_bloc library
A Flutter library for managing API calls using the BLoC pattern. This library provides a set of classes and utilities to simplify API calls and manage state changes.
Classes
-
ApiBloc<
Request extends BlocController< BlocStates> > - A class that initiate the BlocController and inject its value into its descendants.
-
BlocBuilder<
Request extends BlocController< State> , State extends BlocStates> - A widget that rebuilds its descendants when BlocStates changes.
-
BlocConsumer<
Request extends BlocController< State> , State extends BlocStates> - A widget to listen and rebuilds its descendants when BlocStates changes.
-
BlocController<
T extends BlocStates> - Ancestor class of controller used in this package.
-
BlocListener<
Request extends BlocController< State> , State extends BlocStates> - A widget to listen changes in BlocController.
-
BlocStates<
T extends dynamic> - All states that can be represented in BlocController.
- ReadController
-
An extended abstract class of BlocController specifically made for
fetching api request. Normally used for interacting with http method
GET
. -
ReadErrorState<
T extends dynamic> - Represents the error state when an error occurs during data fetching in ReadController.
-
ReadLoadingState<
T extends dynamic> - Represents the loading state when data is being fetched in ReadController.
-
ReadStates<
T extends dynamic> - The base state class used in ReadController.
-
ReadSuccessState<
T extends Object> - Represents the success state when data fetching is successful in ReadController.
- WriteController
-
An extended abstract class of BlocController specifically made for
submitting api request. Normally used for interacting with http method
POST
,PUT
,PATCH
,DELETE
. -
WriteErrorState<
T extends dynamic> - Represents the error state when an error occurs during request submission in WriteController.
-
WriteFailedState<
T extends Object> - Represents the failed state when a request submission fails in WriteController.
-
WriteIdleState<
T extends dynamic> - Represents the idle state when no request is in progress in WriteController.
-
WriteLoadingState<
T extends dynamic> - Represents the loading state when a request is in progress in WriteController.
-
WriteStates<
T extends dynamic> - The base state class used in WriteController.
-
WriteSuccessState<
T extends Object> - Represents the success state when a request is successfully submitted in WriteController.
Extensions
- ApiBlocExtension on BuildContext
- A collection of extension used in ApiBloc library.
Typedefs
-
OnBlocBuilder<
State extends BlocStates> = Widget Function(BuildContext context, State state, Widget child) - A shortcut for calling builder function which is used in BlocConsumer and BlocBuilder.
-
OnBlocListener<
State extends BlocStates> = void Function(BuildContext context, State state) - A shortcut for calling listener function which is used in BlocConsumer and BlocListener.
Exceptions / Errors
- ApiBlocException
- An exception thrown when an error occurs in the ApiBloc library.