flutter_bloc_side_effect
library
Classes
-
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<Bloc extends StateStreamable<State>, State>
-
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.
-
BlocBuilderWithSideEffects<Bloc extends SideEffectProvider<SideEffect, State>, State, SideEffect>
-
Extended version of rfb.BlocBuilder which also allows listening to the
mixed side effects if provided
-
BlocConsumer<Bloc extends StateStreamable<State>, State>
-
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.
-
BlocConsumerWithSideEffects<Bloc extends SideEffectProvider<SideEffect, State>, State, SideEffect>
-
Extended version of rfb.BlocConsumer which also allows listening to the
mixed side effects if provided
-
BlocEventSink<Event extends Object?>
-
An ErrorSink that supports adding events.
-
BlocListener<Bloc extends StateStreamable<State>, State>
-
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.
-
BlocListenerWithSideEffects<Bloc extends SideEffectProvider<SideEffect, State>, State, SideEffect>
-
Extended version of rfb.BlocListener which also allows listening to the
mixed side effects if provided
-
BlocObserver
-
An interface for observing the behavior of Bloc instances.
-
BlocOverrides
-
This class facilitates overriding BlocObserver and EventTransformer.
It should be extended by another class in client code with overrides
that construct a custom implementation. The implementation in this class
defaults to the base blocObserver and eventTransformer implementation.
For example:
-
BlocSideEffectListener<B extends SideEffectProvider<SideEffect, S>, S, SideEffect>
-
Takes a BlocWidgetSideEffectListener and an optional bloc and invokes
the listener in response to
side effect
emits in the bloc.
It should be used for functionality that needs to occur only in response to
a side effect
emit such as navigation, showing a SnackBar
, showing
a Dialog
, etc...
The listener is guaranteed to only be called once for each side effect
.
-
BlocSideEffectListenerBase<B extends SideEffectProvider<SideEffect, State_>, State_, SideEffect>
-
Base for widgets that listen to side effect emits in a specified bloc.
-
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.
-
Emittable<State extends Object?>
-
An object that can emit new states.
-
Emitter<State>
-
An Emitter is a class which is capable of emitting new states.
-
ErrorSink
-
A generic destination for errors.
-
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.
-
Transition<Event, State>
-
A Transition is the change from one state to another.
Consists of the currentState, an event, and the nextState.
Mixins
-
BlocSideEffectMixin<Event, State, SideEffect>
-
Mixin to enrich the existing bloc with
Stream
of Side effects
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
.
-
BlocWidgetSideEffectListener<SideEffect>
= void Function(BuildContext context, SideEffect sideEffect)
-
Signature for the
listener
function which takes the BuildContext
along
with the side effect
.
-
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.