leancode_cubit_utils_cqrs library
A library for building cubits for handling CQRS with less boilerplate code.
Classes
-
ArgsQueryCubit<
TArgs, TRes, TOut> - Base class for all request cubits that perform a CQRS query and require arguments.
-
ArgsRequestCubit<
TArgs, TRes, TData, TOut, TError> - Base class for all request cubits which require arguments.
-
BaseRequestCubit<
TRes, TData, TOut, TError> - Base class for all request cubits.
-
Failure<
T> - A class which represents a failure result.
- PaginatedArgs
- Arguments for a paginated cubit request.
- PaginatedConfig
- Configures the parameters in PaginatedCubits.
- PaginatedConfigProvider
- Provides the default configuration for all PaginatedCubits.
-
PaginatedCubit<
TData, TRes, TResData, TItem> - Base class for all paginated cubits.
-
PaginatedCubitBuilder<
TData, TItem> - A widget that rebuilds when the state of a PaginatedCubit changes.
-
PaginatedCubitLayout<
TData, TItem> - A layout for a paginated cubit.
- PaginatedLayoutConfig
- A configuration for PaginatedCubitLayout.
- PaginatedLayoutConfigProvider
- A provider for default configuration for PaginatedLayoutConfigProvider.
-
PaginatedQueryCubit<
TData, TRes, TItem> -
An implementation of PaginatedCubit which handles
QueryResult
responses. -
PaginatedResponse<
TData, TItem> - A response containing a list of items and a flag indicating whether there is a next page.
-
PaginatedState<
TData, TItem> - Represents the state of a PaginatedCubit.
-
PreRequest<
TRes, TResData, TData, TItem> - Base class for all pre-request use cases.
-
QueryCubit<
TRes, TOut> - Base class for all request cubits that perform a CQRS query and do not require any arguments.
-
QueryPreRequest<
TRes, TData, TItem> -
An implementation of PreRequest which handles
QueryResult
responses. -
RequestCubit<
TRes, TData, TOut, TError> - Base class for all request cubits which don't require any arguments.
-
RequestCubitBuilder<
TOut, TError> - A widget that builds itself based on the latest request state.
- RequestCubitConfig
- Configures the RequestCubits.
-
RequestEmptyState<
TOut, TError> - Represents a successful request with empty data.
-
RequestErrorState<
TOut, TError> - Represents a failed request.
-
RequestInitialState<
TOut, TError> - Represents the initial state of a request.
- RequestLayoutConfig
- A default root config.
- RequestLayoutConfigProvider
- A widget that provides default loading and error widgets for RequestCubitBuilder.
-
RequestLoadingState<
TOut, TError> - Represents the loading state of a request.
-
RequestRefreshState<
TOut, TError> - Represents the refresh state of a request.
-
RequestResult<
T> - A class which represents a result which can be either a success or a failure.
-
RequestState<
TOut, TError> - Represents the state of a request.
-
RequestSuccessState<
TOut, TError> - Represents a successful request.
-
SimpleArgsQueryCubit<
TArgs, TOut> - Simplified implementation of ArgsQueryCubit created in order to be used by useArgsQueryCubit.
-
SimpleArgsQueryWithEmptyCubit<
TArgs, TOut> - Simplified implementation of ArgsQueryCubit created in order to be used by useArgsQueryCubit. Differ from SimpleArgsQueryCubit because it uses a custom function to check if the data is empty.
-
SimpleQueryCubit<
TOut> - Simplified implementation of QueryCubit created in order to be used by useQueryCubit.
-
SimpleQueryWithEmptyCubit<
TOut> - Simplified implementation of QueryCubit created in order to be used by useQueryCubit. Differ from SimpleQueryCubit because it uses a custom function to check if the data is empty.
-
Success<
T> - A class which represents a success result.
Enums
- PaginatedStateType
- Type of the PaginatedState.
- PreRequestMode
- Enum defining weather the pre-request should be run once or each time the first page is loaded.
- RequestMode
- Defines how to handle a new request when the previous one is still running.
Mixins
-
QueryResultHandler<
TRes, TOut> - A mixin that handles the result of a CQRS query.
Functions
-
useArgsQueryCubit<
TArgs, TOut> (ArgsRequest< TArgs, QueryResult< request, {String loggerTag = 'SimpleArgsQueryCubit', RequestMode? requestMode, List<TOut> >Object?> keys = const []}) → SimpleArgsQueryCubit<TArgs, TOut> -
Provides a ArgsQueryCubit specialized for
QueryResult
that is automatically disposed without having to use BlocProvider and requires arguments. It is a wrapper ofuseBloc
that creates a SimpleArgsQueryCubit. -
useArgsQueryWithEmptyCubit<
TArgs, TOut> (ArgsRequest< TArgs, QueryResult< request, EmptyChecker<TOut> >TOut> isEmpty, {String loggerTag = 'SimpleArgsQueryWithEmptyCubit', RequestMode? requestMode, List<Object?> keys = const []}) → SimpleArgsQueryWithEmptyCubit<TArgs, TOut> -
Provides a ArgsQueryCubit specialized for
QueryResult
that is automatically disposed without having to use BlocProvider and requires arguments. It is a wrapper ofuseBloc
that creates a SimpleArgsQueryWithEmptyCubit. Differ from useArgsQueryCubit because it uses a custom function to check if the data is empty. -
useQueryCubit<
TOut> (Request< QueryResult< request, {String loggerTag = 'SimpleQueryCubit', RequestMode? requestMode, bool callOnCreate = true, List<TOut> >Object?> keys = const [], EmptyChecker<TOut> ? isEmpty}) → SimpleQueryCubit<TOut> -
Provides a QueryCubit specialized for
QueryResult
that is automatically disposed without having to use BlocProvider and does not require any arguments. It is a wrapper ofuseBloc
that creates a SimpleQueryCubit. -
useQueryWithEmptyCubit<
TOut> (Request< QueryResult< request, EmptyChecker<TOut> >TOut> isEmpty, {String loggerTag = 'SimpleQueryWithEmptyCubit', RequestMode? requestMode, bool callOnCreate = true, List<Object?> keys = const []}) → SimpleQueryWithEmptyCubit<TOut> -
Provides a QueryCubit specialized for
QueryResult
that is automatically disposed without having to use BlocProvider and does not require any arguments. It is a wrapper ofuseBloc
that creates a SimpleQueryWithEmptyCubit. Differ from useQueryCubit because it uses a custom function to check if the data is empty.
Typedefs
-
ArgsRequest<
TArgs, TRes> = Future< TRes> Function(TArgs) - Signature for a function that performs a request with given arguments.
-
EmptyChecker<
TRes> = bool Function(TRes) - Signature for a function that checks if the request response is empty.
-
ErrorMapper<
TOut, TError> = Future< TOut> Function(RequestErrorState<TOut, TError> ) - Signature for a function that maps request error to other state.
-
PaginatedErrorBuilder<
TItem> = Widget Function(BuildContext context, Object? error, VoidCallback retry) - A builder for the error state widget in PaginatedCubitLayout.
-
PaginatedItemBuilder<
TData, TItem> = Widget Function(BuildContext context, TData? data, int index, List< TItem> items) - A builder for a paginated list item.
-
PaginatedWidgetBuilder<
TData, TItem> = Widget Function(BuildContext context, PaginatedState< TData, TItem> state) - A builder for a widget using the paginated state and data.
-
Request<
TRes> = Future< TRes> Function() - Signature for a function that performs a request.
-
RequestErrorBuilder<
TError> = Widget Function(BuildContext context, RequestErrorState< dynamic, TError> error, VoidCallback retry) - Signature for a function that creates a widget when request is loading.
-
RequestWidgetBuilder<
TOut> = Widget Function(BuildContext context, TOut data) - Signature for a function that creates a widget when data successfully loaded.
-
ResponseMapper<
TRes, TOut> = TOut Function(TRes) - Signature for a function that maps request response of to the output type.