A ScopeObserver that hands every event to each of observers, in order.
ScopeConfig.observer holds one observer, and wanting two is ordinary — ScopePrintObserver while developing and a crash reporter of your own beside it:
ScopeConfig.observer = const ScopeCompositeObserver([
ScopePrintObserver(),
CrashReporter(),
]);
Written here rather than left to be written by hand, and that is the point of it. ScopeObserver has empty hooks, so a subclass keeps compiling when a new hook is added — which is what protects an ordinary observer from a new version. A delegate is the one subclass that gets nothing from it: the new hook arrives with the empty implementation of the base, and every observer behind the delegate stops hearing that event without a word from anywhere. This one is written with the class it forwards, and grows with it.
An observer that throws does not stop the ones after it: every observer is asked, and then the first failure is thrown on to whoever called the composite, the way a single observer that throws would have done. The package catches it there and reports it through FlutterError.reportError, and the event counts as unheard — a failure meant only for the observer goes to FlutterError as well, rather than nowhere. A second failure in the same call is reported here, since only one can be thrown. Called by hand, outside the package, the composite throws what its first failing observer threw.
An empty composite, or one made only of empty composites, hears nothing,
and the package treats it as no observer at all: a failure meant only for
the observer goes to FlutterError, as it does with
ScopeConfig.observer at null.
- Inheritance
-
- Object
- ScopeObserver
- ScopeCompositeObserver
Constructors
-
ScopeCompositeObserver(List<
ScopeObserver> observers) -
Creates an observer that forwards to each of
observers.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
observers
→ List<
ScopeObserver> -
The observers this one stands in front of, asked in order.
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
-
onCancelled(
ScopeObservable target) → void -
An initialization was cancelled before it finished.
override
-
onDisposalStarted(
ScopeObservable target) → void -
A teardown has begun.
override
-
onDisposalStepFinished(
ScopeObservable target, String path) → void -
One step of a disposal is done;
pathnames the dependency released.override -
onDisposalStepStarted(
ScopeObservable target, String path) → void -
One step of a disposal has begun;
pathnames it.override -
onDisposed(
ScopeObservable target) → void -
A teardown has finished.
override
-
onError(
ScopeObservable target, ScopePhase phase, ScopeErrorRoute route, Object error, StackTrace? stackTrace) → void -
Something failed;
phasesays what was running.override -
onInitialized(
ScopeObservable target) → void -
An initialization has finished successfully.
override
-
onInitStarted(
ScopeObservable target) → void -
An initialization has begun.
override
-
onProgress(
ScopeObservable target, Object? progress) → void -
One step of an initialization is done.
override
-
onStepStarted(
ScopeObservable target, String path) → void -
One step of an initialization has begun;
pathnames it.override -
onTimeout(
ScopeObservable target, String what, TimeoutException error, StackTrace stackTrace) → void -
A bounded wait expired;
whatnames what was waited for.override -
onTrace(
ScopeObservable target, String message) → void -
A step of the machinery below the lifecycle.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited