SurgeObserver class abstract
Abstract observer class for monitoring Surge lifecycle events.
SurgeObserver provides a way to observe and react to Surge lifecycle events, including creation, state changes, and disposal. This is useful for debugging, logging, or implementing cross-cutting concerns.
To use an observer, create a subclass and override the methods you're interested in, then set it as the global observer:
Example:
class MyObserver extends SurgeObserver {
@override
void onCreate(Surge surge) {
print('Surge created: $surge');
}
@override
void onChange(Surge surge, Change change) {
print('State changed: ${change.currentState} -> ${change.nextState}');
}
@override
void onDispose(Surge surge) {
print('Surge disposed: $surge');
}
}
SurgeObserver.observer = MyObserver();
Constructors
- SurgeObserver()
-
Creates a new observer instance.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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(
Surge surge, Change change) → void - Called when a Surge's state changes.
-
onCreate(
Surge surge) → void - Called when a Surge is created.
-
onDispose(
Surge surge) → void - Called when a Surge is disposed.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- observer ↔ SurgeObserver?
-
The global observer instance for all Surge lifecycle events.
getter/setter pair