Initialisable class abstract
An abstract class that provides initialization and disposal mechanisms.
This class ensures that any subclass is initialized upon creation and can be disposed of when no longer needed. It provides a mechanism to check if the instance is ready or initialized.
Example usage:
class MyService extends Initialisable {
@override
Future<void> initialise() async {
await super.initialise();
// Additional initialization code here
}
}
- Implementers
Constructors
- Initialisable.new({bool tryAutoInitialise = true})
- Constructs an Initialisable instance and calls initialise.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialised → bool
-
Indicates whether the instance is initialized.
no setter
- isReady → Future
-
A Future that completes when the instance is ready.
no setter
- isReadyCompleter ↔ Completer
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
assertInitialised(
) → void - Asserts that the instance is initialized.
-
assertNotDisposed(
) → void - Asserts that the instance is not disposed.
-
dispose(
) → void - Disposes of the instance, resetting its state.
-
initialise(
) → void - Initializes the instance.
-
markAsReady(
) → void - Completes the isReadyCompleter completer if it is not already complete.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
throwIfDisposed(
) → void - Throws a StateError if the instance is disposed.
-
throwIfNotInitialised(
) → void - Throws a StateError if the instance is not initialized.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited