softcore library

A thin, predictable state layer on top of flutter_bloc.

Classes

ActionFailed<T>
An action failed.
ActionLoading<T>
An action started.
ActionResult<R>
The outcome of BaseCubit.runAction.
ActionState<T>
A one-shot state for a user action. Extend it to add your own events.
ActionSuccess<T>
An action finished successfully.
BaseCubit<T>
A Cubit for screens that load data of type T and run actions.
BuildState<T>
A state the UI renders. Extend it to add your own screen states.
DataFailed<T>
Loading data failed.
DataInitial<T>
Nothing has been requested yet.
DataLoading<T>
Data is being loaded.
DataObserver<T>
An independent piece of loadable data inside a bigger cubit.
DataObserverBuilder<T>
Renders one DataObserver: its own loading, error and data, independent of the rest of the screen.
DataState<T>
Base type of every state a softcore bloc emits.
DataStateView<T>
Renders one DataState: loading, error, data, initial, or your own.
DataSuccess<T>
Data loaded successfully.
NoParams
Params for a UseCase that takes none.
SoftBlocConsumer<B extends StateStreamable<DataState<T>>, T>
Renders a bloc that emits DataStates, such as a BaseCubit, and handles its actions.
SoftBlocListener<B extends StateStreamable<DataState<T>>, T>
Handles a bloc's actions without rendering its data: progress while an action runs, a message when it fails, onActionSuccess when it succeeds.
SoftBlocPage<B extends BaseCubit<T>, T>
A whole screen driven by a BaseCubit: creates the cubit, loads once, renders loading/error/data, handles actions, and closes the cubit.
SoftCache
A small in-memory cache keyed by string.
SoftCore
Provides a SoftCoreConfig to the widgets below it.
SoftCoreConfig
App-wide defaults for every softcore widget.
SoftError
An error ready to show: what the error views and messages display.
SoftErrorView
The default error view: the message and a retry button.
SoftLoadingView
The default loading view: a centered spinner.
UseCase<T, P>
A single business operation, the "use case" of clean architecture.

Extensions

DataStateX on DataState<T>
Convenience accessors on any DataState.

Functions

defaultErrorMapper(BuildContext context, Object error) → SoftError
The built-in ErrorMapper.

Typedefs

ActionErrorCallback = void Function(BuildContext context, SoftError error)
Called when an action fails. Replaces the default error message.
ActionSuccessCallback = void Function(BuildContext context, Object? result)
Called when an action succeeds, with what the action returned.
DataWidgetBuilder<T> = Widget Function(BuildContext context, T data)
Builds the widget for data of type T.
ErrorMapper = SoftError Function(BuildContext context, Object error)
Turns any thrown error into a SoftError.
ErrorMessenger = void Function(BuildContext context, SoftError error)
Tells the user an action failed (a snackbar by default).
ErrorViewBuilder = Widget Function(BuildContext context, SoftError error, VoidCallback? onRetry)
Builds the view for an error, with onRetry when retrying is possible.

Exceptions / Errors

LocalizedException
A SoftException with a message per language.
SoftException
An exception with a message that is safe to show to the user.