bloc_plus library

Extensions, widgets, policies, and async helpers for flutter_bloc.

Classes

BlocBuilderWithBloc<B extends BlocBase<S>, S>
A BlocBuilderBase variant that also passes the resolved bloc instance to builder.
BlocConsumerWithBloc<B extends BlocBase<S>, S>
A BlocConsumer variant that passes the resolved bloc instance to both listener and builder.
BlocListenerWithBloc<B extends BlocBase<S>, S>
A BlocListenerBase variant that also passes the resolved bloc instance to the listener callback.
BlocSelectorWithBloc<B extends BlocBase<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.
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.

Mixins

HasEffects<S, E>
Adds a broadcast effect stream to a bloc and closes it with the bloc.
SafeEmitMixin<S>
Adds guarded emit helpers that no-op after a bloc has been closed.

Extensions

BlocContextExtension on BuildContext
Adds null-safe bloc lookup helpers to BuildContext.

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.
onChangeListen<S, T>(T selector(S state)) ListenPolicy<S>
Listens only when the selected value changes.

Typedefs

BlocSelectedCondition<T> = bool Function(T previous, T current)
Signature for deciding whether a newly selected value should trigger a rebuild.
BlocSelectorBuilderWithBloc<B extends BlocBase<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 BlocBase<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 BlocBase<S>, S> = void Function(BuildContext context, B bloc, S state)
Signature for listening to state changes with access to the resolved bloc.