abstract_bloc library

Classes

AbstractConfiguration
AbstractFormBaseState
Base state class for managing form data in BLoC/Cubit patterns.
AbstractFormBasicState<TModel>
State class for forms that manage a data model.
AbstractFormBloc<S extends AbstractFormBaseState>
An abstract Bloc for managing form state using the event-driven pattern.
AbstractFormBuilder<B extends StateStreamableSource<S>, S extends AbstractFormBaseState>
A widget for building forms with state management and event handling. This widget integrates with AbstractFormBaseState and provides callbacks for initialization, submission, success, and error handling.
AbstractFormBusBridgeBloc<S extends AbstractFormState<dynamic, ModelValidator>>
A bridge between a form BLoC (AbstractFormBloc) and an event bus.
AbstractFormBusBridgeCubit<S extends AbstractFormBaseState>
A Cubit that bridges form state with an event bus.
AbstractFormBusObserverBloc<S extends AbstractFormState<dynamic, ModelValidator>>
A BLoC that observes events from an event bus and processes them.
AbstractFormBusObserverCubit<S extends AbstractFormBaseState>
A base cubit class for observing events from an event bus. This class extends AbstractFormCubit and listens to a global event bus. Subclasses must implement the observe method to handle incoming events.
AbstractFormBusPublisherBloc<S extends AbstractFormState<dynamic, ModelValidator>>
A BLoC that publishes its state updates to an event bus.
AbstractFormBusPublisherCubit<S extends AbstractFormBaseState>
A base cubit class for publishing state changes to an event bus. This class extends AbstractFormCubit and automatically publishes its state changes to a global event bus using attachToEventBus.
AbstractFormCubit<S extends AbstractFormBaseState>
An abstract Cubit for managing form state with support for initialization, validation, submission, and offline fallback.
AbstractFormErrorContainer
A widget for displaying an error message and a retry button in a form. This widget is typically used when a form encounters an error and needs to provide the user with an option to retry the operation.
AbstractFormEvent
A base abstract class for form-related events. This class serves as a parent for all form events, such as initialization, updates, and submissions.
AbstractFormInitEvent
An event representing the initialization of a form. This event can carry an optional model to initialize the form.
AbstractFormNoDataContainer
A widget for displaying a "no data" message and a retry button in a form. This widget is typically used when a form has no data to display and provides the user with an option to retry fetching or loading the data.
AbstractFormState<TModel, TModelValidator extends ModelValidator>
Full-featured state class for forms with model and validation support.
AbstractFormSubmitEvent<TModel>
An event representing the submission of a form. This event is generic and can carry a model of any type TModel.
AbstractFormUpdateEvent<TModel>
An event representing an update to the form's model. This event is generic and can carry a model of any type TModel.
AbstractItemBloc<S extends AbstractItemState>
AbstractItemBuilder<B extends StateStreamableSource<S>, S extends AbstractItemState>
A generic widget for displaying different states of an item using BLoC or Cubit pattern.
AbstractItemBusBridgeBloc<S extends AbstractItemState>
An abstract class that serves as a bridge between an event bus and the Item BLoC.
AbstractItemBusBridgeCubit<S extends AbstractItemState>
An abstract class that connects an item Cubit with an event bus.
AbstractItemBusObserverBloc<S extends AbstractItemState>
An abstract class that observes events from an event bus and interacts with an Item BLoC.
AbstractItemBusObserverCubit<S extends AbstractItemState>
An abstract class that observes events from an event bus in the context of an item Cubit.
AbstractItemBusPublisherBloc<S extends AbstractItemState>
An abstract class that publishes state changes to an event bus from an Item BLoC.
AbstractItemBusPublisherCubit<S extends AbstractItemState>
An abstract class that publishes state changes to an event bus in the context of an item Cubit.
AbstractItemCubit<S extends AbstractItemState>
An abstract class that serves as a base for item Cubits, providing functionality for loading and processing data states.
AbstractItemErrorContainer
A widget to display an error message with an option to reload.
AbstractItemEvent
An abstract base class representing an event related to an item.
AbstractItemFilterableState<TSearchModel, TItem>
An abstract class representing a filterable item state with generic types for both the search model TSearchModel and the item TItem.
AbstractItemLoadEvent<TSearchModel>
An event representing a request to load an item, optionally with a search model.
AbstractItemNoDataContainer
A widget to display a message indicating no data is available, with an option to reload.
AbstractItemState<TItem>
An abstract base class representing the state of an item with generic type TItem.
AbstractLisErrorContainer
A widget that displays an error message with an option to retry.
AbstractListBloc<S extends AbstractListState>
An abstract Bloc for managing list-based state using the event-driven pattern.
AbstractListBuilder<B extends StateStreamableSource<S>, S extends AbstractListState>
A generic widget for building lists that support state management, pagination, and refresh functionalities.
AbstractListBusBridgeBloc<S extends AbstractListState>
An abstract class that bridges the list bloc with an event bus. It listens to events on the event bus and allows for state changes based on those events.
AbstractListBusBridgeCubit<S extends AbstractListState>
An abstract class that acts as a bridge for integrating the cubit with an event bus. It allows the cubit to publish its state and also to listen for events from the event bus.
AbstractListBusObserverBloc<S extends AbstractListState>
An abstract class that acts as a bloc observer for listening to events from an event bus. This allows the bloc to react to external events outside its normal flow.
AbstractListBusObserverCubit<S extends AbstractListState>
An abstract class that allows a cubit to observe events from an event bus. Subclasses must implement logic to handle these events.
AbstractListBusPublisherBloc<S extends AbstractListState>
An abstract class that enables publishing state changes to an event bus. This allows other parts of the application to react to state changes in this bloc.
AbstractListBusPublisherCubit<S extends AbstractListState>
An abstract class that enables a cubit to publish its state to an event bus. This allows other components to react to state changes outside the cubit.
AbstractListCubit<S extends AbstractListState>
An abstract Cubit for managing list-based state with support for loading, refreshing, pagination, filtering, and caching.
AbstractListEvent
An abstract class that defines the base for all list-related events.
AbstractListFilterablePaginatedState<TSearchModel extends BasePagination, TListItem>
State class for paginated lists with filtering and load-more support.
AbstractListFilterableState<TSearchModel, TListItem>
State class for filterable lists with search model support.
AbstractListLoadEvent<TSearchModel>
An event that signifies a request to load data into a list.
AbstractListLoadMoreEvent
An event that signifies a request to load more data into the list.
AbstractListNoDataContainer
A widget that displays a message indicating that no data is available.
AbstractListRefreshEvent
An event that signifies a request to refresh the currently loaded list data.
AbstractListState<TListItem>
Base state class for managing list data in BLoC/Cubit patterns.
AbstractTranslations
A class that holds the abstract translations for various UI prompts and messages.
AuthHandler
Handles JWT authentication, token storage, and automatic token refresh.
AuthOptions
Configuration options for JWT authentication and automatic token refresh.
BackgroundTransformer
The default Transformer for Dio.
BaseOptions
A set of base settings for each Dio(). BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
Bloc<Event, State>
Takes a Stream of Events as input and transforms them into a Stream of States as output.
BlocBase<State>
An interface for the core functionality implemented by both Bloc and Cubit.
BlocBuilder<B extends StateStreamable<S>, S>
BlocBuilder handles building a widget in response to new states. BlocBuilder is analogous to StreamBuilder but has simplified API to reduce the amount of boilerplate code needed as well as bloc-specific performance improvements. Please refer to BlocListener if you want to "do" anything in response to state changes such as navigation, showing a dialog, etc...
BlocBuilderBase<B extends StateStreamable<S>, S>
Base class for widgets that build themselves based on interaction with a specified bloc.
BlocConsumer<B extends StateStreamable<S>, S>
BlocConsumer exposes a builder and listener in order react to new states. BlocConsumer is analogous to a nested BlocListener and BlocBuilder but reduces the amount of boilerplate needed. BlocConsumer should only be used when it is necessary to both rebuild UI and execute other reactions to state changes in the bloc.
BlocEventSink<Event extends Object?>
An ErrorSink that supports adding events.
BlocListener<B extends StateStreamable<S>, S>
Takes a BlocWidgetListener and an optional bloc and invokes the listener in response to state changes in the bloc. It should be used for functionality that needs to occur only in response to a state change such as navigation, showing a SnackBar, showing a Dialog, etc... The listener is guaranteed to only be called once for each state change unlike the builder in BlocBuilder.
BlocListenerBase<B extends StateStreamable<S>, S>
Base class for widgets that listen to state changes in a specified bloc.
BlocObserver
An interface for observing the behavior of Bloc instances.
BlocProvider<T extends StateStreamableSource<Object?>>
Takes a create function that is responsible for creating the Bloc or Cubit and a child which will have access to the instance via BlocProvider.of(context). It is used as a dependency injection (DI) widget so that a single instance of a Bloc or Cubit can be provided to multiple widgets within a subtree.
BlocSelector<B extends StateStreamable<S>, S, T>
BlocSelector is analogous to BlocBuilder but allows developers to filter updates by selecting a new value based on the bloc state. Unnecessary builds are prevented if the selected value does not change.
BusBridgeBloc<S, E>
A Bloc that acts as a mediator between its state changes and an EventBus.
BusBridgeCubit<S>
A Cubit that acts as a mediator between its state changes and an EventBus.
BusObserverBloc<S, E>
A Bloc that observes events from an EventBus.
BusObserverCubit<S>
A Cubit that observes events from an EventBus.
BusPublisherBloc<S, E>
A Bloc that publishes its state changes to an EventBus.
BusPublisherCubit<S>
A Cubit that publishes its state changes to an EventBus.
CacheHandler
A class for managing cached data to optimize API request handling.
CacheModel
A model representing cached data along with its expiration time.
CacheOptions
Configuration options for caching responses in API calls.
CacheResult<T>
Represents a result that comes from cache.
CancelToken
Controls cancellation of Dio's requests.
Change<State>
A Change represents the change from one State to another. A Change consists of the currentState and nextState.
Closable
An object that must be closed when no longer in use.
CopyWith<T>
A base abstract class for enabling the copyWith pattern. Classes that implement this interface must provide a copyWith method, which is commonly used to create a new instance of the class with modified properties.
Cubit<State>
A Cubit is similar to Bloc but has no notion of events and relies on methods to emit new states.
Dio
Dio enables you to make HTTP requests easily.
DioMixin
Emittable<State extends Object?>
An object that can emit new states.
EmittableStateStreamableSource<State>
A StateStreamableSource that can emit new states.
Emitter<State>
An Emitter is a class which is capable of emitting new states.
ErrorInterceptorHandler
The handler for interceptors to handle error occurred during the request.
ErrorResult<T>
Represents an error result.
ErrorSink
A generic destination for errors.
Event
EventBus
ExceptionHandler
Handles exceptions thrown by Dio during API calls. Converts DioException into custom BaseException types.
ExceptionOptions
This class is part of the exception handling mechanism implemented in the RestApiClient.
FormData
A class to create readable "multipart/form-data" streams. It can be used to submit forms and file uploads to http server.
FusedTransformer
A Transformer that has a fast path for decoding UTF8-encoded JSON. If the response is utf8-encoded JSON and no custom decoder is specified in the RequestOptions, this transformer is significantly faster than the default SyncTransformer and the BackgroundTransformer. This improvement is achieved by using a fused Utf8Decoder and JsonDecoder to decode the response, which is faster than decoding the utf8-encoded JSON in two separate steps, since Dart uses a special fast decoder for this case. See https://github.com/dart-lang/sdk/blob/5b2ea0c7a227d91c691d2ff8cbbeb5f7f86afdb9/sdk/lib/_internal/vm/lib/convert_patch.dart#L40
GridResult<TListItem>
A class representing the result of a paginated grid, containing a list of items and pagination-related metadata.
GridResultJsonConfiguration
A utility class that provides JSON key configurations for the GridResult.
Headers
The headers class for requests and responses.
HttpClientAdapter
HttpAdapter is a bridge between Dio and HttpClient.
IEventBus
InfoDialog
A customizable information dialog widget.
InitialEvent
Interceptor
Interceptor helps to deal with RequestOptions, Response, and DioException during the lifecycle of a request before it reaches users.
Interceptors
A Queue-Model list for Interceptors.
InterceptorsWrapper
A helper class to create interceptors in ease.
ListParam<T>
Indicates a param being used as queries or form data, and how does it gets formatted.
LocalErrorResult<T>
Represents a local error result (e.g., a caching error).
LocalSuccessResult<T>
Represents a successful local (cached) result.
LoggingOptions
Options to customize logging of HTTP requests and responses.
LogInterceptor
LogInterceptor is used to print logs during network requests. It should be the last interceptor added, otherwise modifications by following interceptors will not be logged. This is because the execution of interceptors is in the order of addition.
ModelValidator
A base abstract class for model validation. This class provides default implementations for common validation methods, such as validating a model, retrieving validation messages, and formatting messages.
MultiBlocListener
Merges multiple BlocListener widgets into one widget tree.
MultiBlocObserver
A BlocObserver which supports registering multiple BlocObserver instances. This is useful when maintaining multiple BlocObserver instances for different functions e.g. LoggingBlocObserver, ErrorReportingBlocObserver.
MultiBlocProvider
Merges multiple BlocProvider widgets into one widget tree.
MultipartFile
An upload content that is a part of MultipartRequest. This doesn't need to correspond to a physical file.
MultiRepositoryProvider
Merges multiple RepositoryProvider widgets into one widget tree.
NetworkResult<T>
Represents a network result that includes the response.
Options
The configuration for a single request. BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
Pagination
PaginationConfiguration
A class representing pagination configuration options.
PropertyValidator<T>
A base abstract class for validating a specific property of a model. This class is generic and can be used to validate properties of any type T. Subclasses must implement the validate method to provide custom validation logic.
QueuedInterceptor
Interceptor in queue.
QueuedInterceptorsWrapper
A helper class to create QueuedInterceptor in ease.
RedirectRecord
A record that records the redirection happens during requests, including status code, request method, and the location.
RefreshTokenInterceptor
A Dio interceptor that handles automatic JWT token refresh.
RepositoryProvider<T>
Takes a create function that is responsible for creating the repository and a child which will have access to the repository via RepositoryProvider.of(context). It is used as a dependency injection (DI) widget so that a single instance of a repository can be provided to multiple widgets within a subtree.
RequestDeduplicationInterceptor
A Dio interceptor that deduplicates identical concurrent requests.
RequestInterceptorHandler
The handler for interceptors to handle before the request has been sent.
RequestOptions
The internal request option class that is the eventual result after BaseOptions and Options are composed.
Response<T>
The Response class contains the payload (could be transformed) that respond from the request, and other information of the response.
ResponseBody
The response wrapper class for adapters.
ResponseInterceptorHandler
The handler for interceptors to handle after respond.
RestApiClient
An abstract class representing a REST API client.
RestApiClientHeaders
A class that contains commonly used HTTP headers for the REST API client.
RestApiClientImpl
Implementation of the RestApiClient interface using the Dio HTTP client.
RestApiClientKeys
RestApiClientOptions
Options to configure the RestApiClient.
RestApiClientRequestOptions
Options for configuring HTTP requests in the RestApiClient.
Result<T>
A generic Result class to hold the outcome of operations.
RetryInterceptor
A Dio interceptor that automatically retries failed requests with exponential backoff.
RetryOptions
Configuration for automatic request retry with exponential backoff.
StateStreamable<State>
A Streamable that provides synchronous access to the current state.
StateStreamableSource<State>
A StateStreamable that must be closed when no longer in use.
Streamable<State extends Object?>
An object that provides access to a stream of states over time.
SuccessResult<T>
Represents a successful result.
SyncTransformer
If you want to custom the transformation of request/response data, you can provide a Transformer by your self, and replace the transformer by setting the Dio.transformer.
Transformer
Transformer allows changes to the request/response data before it is sent/received to/from the server.
Transition<Event, State>
A Transition is the change from one state to another. Consists of the currentState, an event, and the nextState.

Enums

AbstractScrollBehaviour
Enum to define the behavior of scrollable headers or footers.
DioExceptionType
The exception enumeration indicates what type of exception has happened during requests.
FileAccessMode
The file access mode when downloading a file, corresponds to a subset of dart:io::FileMode.
FormResultStatus
An enumeration representing the various statuses of a form's result.
ListFormat
Specifies the array format (a single parameter with multiple parameter or multiple parameters with the same name). and the separator for array items.
RefreshTokenStrategy
Strategy for handling JWT token refresh.
ResponseType
Indicates which transformation should be applied to the response data.
ResultStatus
An enumeration representing the various statuses of a result in a data-fetching context.

Mixins

OptionsMixin
The mixin class for options that provides common attributes.

Extensions

ReadContext on BuildContext
Exposes the read method.
SelectContext on BuildContext
Adds a select method on BuildContext.
WatchContext on BuildContext
Exposes the watch method.

Properties

eventBus IEventBus
getter/setter pair

Functions

dateTimeFromJson(String? json) DateTime?
Converts a dot-separated string to a DateTime object. The expected format is "YYYY.MM.DD.HH.MM.SS".
defaultDioExceptionReadableStringBuilder(DioException e) String
The default implementation of building a readable string of DioException.

Typedefs

BlocBuilderCondition<S> = bool Function(S previous, S current)
Signature for the buildWhen function which takes the previous state and the current state and is responsible for returning a bool which determines whether to rebuild BlocBuilder with the current state.
BlocListenerCondition<S> = bool Function(S previous, S current)
Signature for the listenWhen function which takes the previous state and the current state and is responsible for returning a bool which determines whether or not to call BlocWidgetListener of BlocListener with the current state.
BlocWidgetBuilder<S> = Widget Function(BuildContext context, S state)
Signature for the builder function which takes the BuildContext and state and is responsible for returning a widget which is to be rendered. This is analogous to the builder function in StreamBuilder.
BlocWidgetListener<S> = void Function(BuildContext context, S state)
Signature for the listener function which takes the BuildContext along with the state and is responsible for executing in response to state changes.
BlocWidgetSelector<S, T> = T Function(S state)
Signature for the selector function which is responsible for returning a selected value, T, based on state.
DefaultTransformer = SyncTransformer
DioError = DioException
DioError describes the exception info when a request failed.
DioErrorType = DioExceptionType
Deprecated in favor of DioExceptionType and will be removed in future major versions.
DioExceptionReadableStringBuilder = String Function(DioException e)
The readable string builder's signature of DioException.readableStringBuilder.
DioMediaType = MediaType
The type (alias) for specifying the content-type of the MultipartFile.
EventHandler<Event, State> = FutureOr<void> Function(Event event, Emitter<State> emit)
An event handler is responsible for reacting to an incoming Event and can emit zero or more states via the Emitter.
EventMapper<Event> = Stream<Event> Function(Event event)
Signature for a function which converts an incoming event into an outbound stream of events. Used when defining custom EventTransformers.
EventTransformer<Event> = Stream<Event> Function(Stream<Event> events, EventMapper<Event> mapper)
Used to change how events are processed. By default events are processed concurrently.
HeaderForEachCallback = void Function(String name, List<String> values)
The signature that iterates header fields.
InterceptorErrorCallback = void Function(DioException error, ErrorInterceptorHandler handler)
The signature of Interceptor.onError.
InterceptorSendCallback = void Function(RequestOptions options, RequestInterceptorHandler handler)
The signature of Interceptor.onRequest.
InterceptorSuccessCallback = void Function(Response response, ResponseInterceptorHandler handler)
The signature of Interceptor.onResponse.
JsonDecodeCallback = FutureOr Function(String)
The callback definition for decoding a JSON string.
JsonEncodeCallback = FutureOr<String> Function(Object)
The callback definition for encoding a JSON object.
ProgressCallback = void Function(int count, int total)
The type of a progress listening callback when sending or receiving data.
RequestEncoder = FutureOr<List<int>> Function(String request, RequestOptions options)
The type of a request encoding callback.
ResponseDecoder = FutureOr<String?> Function(List<int> responseBytes, RequestOptions options, ResponseBody responseBody)
The type of a response decoding callback.
ValidateStatus = bool Function(int? status)
The type of a response status code validate callback.

Exceptions / Errors

BaseException
A base class for exceptions that may occur during HTTP requests/responses when using the RestApiClient.
DioException
DioException describes the exception info when a request failed.
ForbiddenException
A derived exception class that represents a server error when access is forbidden, typically indicating a 403 HTTP status code.
NetworkErrorException
A derived exception class that represents network-related errors during HTTP requests, such as connectivity issues or timeouts.
NotNullableError<T>
A TypeError thrown by _checkNotNullable.
ProviderNotFoundException
The error that will be thrown if Provider.of fails to find a Provider as an ancestor of the BuildContext used.
ServerErrorException
A derived exception class that represents any server error encountered during HTTP requests, typically indicating a 5xx HTTP status code.
UnauthorizedException
A derived exception class that represents unauthorized access errors encountered during HTTP requests, typically indicating a 401 HTTP status code.
ValidationException
A derived exception class that represents any validation errors encountered during API requests, typically related to improper data input.