A common interface defining methods for start/stop lifecycle control.
The typical use case for this is to control asynchronous processing. This interface does not imply specific auto-startup semantics.
Usage Example
class BackgroundTaskManager implements Lifecycle {
bool _running = false;
@override
void start() {
if (!_running) {
startBackgroundTasks();
_running = true;
}
}
@override
void stop() {
if (_running) {
stopBackgroundTasks();
_running = false;
}
}
@override
bool isRunning() => _running;
}
- Implementers
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
-
isRunning(
) → bool - Check whether this component is currently running.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → FutureOr< void> - A common interface defining methods for start/stop lifecycle control.
-
stop(
[Runnable? callback]) → FutureOr< void> - Stop this component, typically in a synchronous fashion.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited