bloc_plus library
Async helpers for Cubits, one-off effects, conditions and widgets for
flutter_bloc.
Classes
-
BlocBuilderWithBloc<
B extends StateStreamable< S> , S> -
A
BlocBuilderwhose builder also receives the resolved bloc. -
BlocConsumerWithBloc<
B extends StateStreamable< S> , S> -
A
BlocConsumervariant that passes the resolved bloc instance to both listener and builder. -
BlocConsumerWithEffects<
B extends HasEffects< S, E> , S, E> - Combines state building, optional state listening and one-off effect handling for a bloc that mixes in HasEffects.
-
BlocEffectListener<
B extends EffectsSource< E> , E> -
Listens to the one-off effects of a bloc that implements EffectsSource
of
E, usually through HasEffects. -
BlocListenerWithBloc<
B extends StateStreamable< S> , S> -
A
BlocListenerwhose listener also receives the resolved bloc. -
BlocSelectorWithBloc<
B extends StateStreamable< S> , S, T> - A selector widget that exposes both the resolved bloc instance and selected value to builder.
- CancellationToken
- Tracks cancellation for async work that may become stale.
-
EffectListener<
B extends BlocBase< S> , S, E> - Listens to one-off effects emitted by blocs implementing EffectsSource.
-
EffectsSource<
E> - Exposes a stream of one-off effects emitted outside the main bloc state.
-
ListenPolicy<
S> - Encapsulates listener decisions for pairs of previous and current state.
- MultiEffectListener
- Composes multiple EffectListener widgets into a single tree level.
-
RebuildPolicy<
S> - Encapsulates rebuild decisions for pairs of previous and current state.
-
RestartableTask<
T> - Runs async work where starting a new task cancels the previous result.
- SingleChildEffectListener
- Contract for effect listener widgets that can wrap a child subtree.
-
TaskOutcome<
T> -
The outcome of a run of
RestartableTask.runOutcomeorRestartableTasksMixin.runLatestOutcome: either the run completed with a value, or it was cancelled (superseded, cancelled explicitly, disposed or closed) and its result was discarded.
Mixins
-
HasEffects<
S, E> - Adds a broadcast effect stream to a bloc and closes it with the bloc.
-
RestartableTasksMixin<
S> - Tracks keyed restartable tasks for "latest request wins" workflows.
-
SafeEmitMixin<
S> - Adds guarded emit helpers that no-op after a cubit has been closed.
Extensions
- BlocContextExtension on BuildContext
- Adds null-safe lookup helpers to BuildContext.
Properties
- debugPrintUnheardEffects ↔ bool
-
Whether HasEffects.emitEffect prints a warning in debug builds for an
effect that nothing listens to.
getter/setter pair
Functions
-
always<
S> () → RebuildPolicy< S> - Rebuilds for every state change.
-
alwaysListen<
S> () → ListenPolicy< S> - Listens for every state change.
-
distinct<
S> () → RebuildPolicy< S> - Rebuilds only when the full state value changes.
-
distinctListen<
S> () → ListenPolicy< S> - Listens only when the full state value changes.
-
never<
S> () → RebuildPolicy< S> - Never rebuilds for state changes.
-
neverListen<
S> () → ListenPolicy< S> - Never listens for state changes.
-
onChange<
S, T> (T selector(S state)) → RebuildPolicy< S> - Rebuilds only when the selected value changes.
-
onChangeBy<
S, T> (T selector(S state), {required bool equals(T previous, T current)}) → RebuildPolicy< S> -
Rebuilds only when the selected value changes according to
equals. -
onChangeListen<
S, T> (T selector(S state)) → ListenPolicy< S> - Listens only when the selected value changes.
-
onChangeListenBy<
S, T> (T selector(S state), {required bool equals(T previous, T current)}) → ListenPolicy< S> -
Listens only when the selected value changes according to
equals. -
whenChanged<
S, T> (T selector(S state), {bool equals(T previous, T current)?}) → BlocCondition< S> -
Returns a condition that holds when the value picked by
selectordiffers between the previous and the current state. -
whenListen<
S> (bool predicate(S previous, S current)) → ListenPolicy< S> -
Wraps
predicateas a reusable listen policy. -
whenRebuild<
S> (bool predicate(S previous, S current)) → RebuildPolicy< S> -
Wraps
predicateas a reusable rebuild policy.
Typedefs
-
BlocCondition<
S> = bool Function(S previous, S current) -
A predicate over a pair of states, usable directly as
buildWhen,listenWhenorselectorShouldRebuild. -
BlocEffectListenerWithBloc<
B extends StateStreamable< S> , S, E> = void Function(BuildContext context, B bloc, E effect) - Signature for handling one-off effects with access to the resolved bloc.
-
BlocSelectedCondition<
T> = bool Function(T previous, T current) - Signature for deciding whether a newly selected value should trigger a rebuild.
-
BlocSelectorBuilderWithBloc<
B extends StateStreamable< S> , S, T> = Widget Function(BuildContext context, B bloc, T selected) - Signature for building a widget from a selected value and the resolved bloc.
-
BlocWidgetBuilderWithBloc<
B extends StateStreamable< S> , S> = Widget Function(BuildContext context, B bloc, S state) - Signature for building a widget with both the resolved bloc and current state.
-
BlocWidgetListenerWithBloc<
B extends StateStreamable< S> , S> = void Function(BuildContext context, B bloc, S state) - Signature for listening to state changes with access to the resolved bloc.
-
EffectCondition<
E> = bool Function(E effect) -
Signature for deciding whether an
effectshould trigger an effect listener.