MultiBlocObserver class
A BlocObserver which supports registering multiple BlocObserver
instances. This is useful when maintaining multiple BlocObserver instances
for different functions e.g. LoggingBlocObserver,
ErrorReportingBlocObserver.
Bloc.observer = MultiBlocObserver(
observers: [
LoggingObserver(),
ErrorObserver(),
PerformanceObserver(),
],
);
- Implemented types
Constructors
-
MultiBlocObserver({required List<
BlocObserver> observers}) -
A BlocObserver which supports registering multiple BlocObserver
instances. This is useful when maintaining multiple BlocObserver instances
for different functions e.g.
LoggingBlocObserver,ErrorReportingBlocObserver.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
observers
→ List<
BlocObserver> -
The list of BlocObserver instances that will be registered. Observers
are notified of all lifecycle events in the same order that they are
specified.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onChange(
BlocBase bloc, Change change) → void -
Called whenever a Change occurs in any
blocAchangeoccurs when a new state is emitted. onChange is called before a bloc's state has been updated.override -
onClose(
BlocBase bloc) → void -
Called whenever a Bloc is closed.
onClose is called just before the Bloc is closed
and indicates that the particular instance will no longer
emit new states.
override
-
onCreate(
BlocBase bloc) → void -
Called whenever a Bloc is instantiated.
In many cases, a cubit may be lazily instantiated and
onCreate can be used to observe exactly when the cubit
instance is created.
override
-
onDone(
Bloc bloc, Object? event, [Object? error, StackTrace? stackTrace]) → void -
Called whenever an
eventhandler for a specificblochas completed. This may include anerrorandstackTraceif an uncaught exception occurred within the event handler.override -
onError(
BlocBase bloc, Object error, StackTrace stackTrace) → void -
Called whenever an
erroris thrown in any Bloc or Cubit. ThestackTraceargument may be StackTrace.empty if an error was received without a stack trace.override -
onEvent(
Bloc bloc, Object? event) → void -
Called whenever an
eventisaddedto anyblocwith the givenblocandevent.override -
onTransition(
Bloc bloc, Transition transition) → void -
Called whenever a transition occurs in any
blocwith the givenblocandtransition. Atransitionoccurs when a neweventis added and a new state isemittedfrom a corresponding EventHandler. onTransition is called before abloc's state has been updated.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited