Configurable class abstract
Configurable
is configuration for scope.
Technical speaking, Configurable
is an interface that
has a configure
method:
abstract class Configurable {
FutureOr<void> configure(ConfigurableScope scope);
}
This configure
method is used to configure scope
during its creation.
Example:
class MyConfigurable implements Configurable {
@override
FutureOr<void> configure(ConfigurableScope scope) {
late final repository = Repository();
late final appNotifier = AppNotifier(
repository: repository,
);
scope.expose<Repository>(expose: () => repository);
scope.expose<AppNotifier>(expose: () => appNotifier);
scope.addDispose(() {
appNotifier.dispose();
});
}
}
Then, using this configuration:
void main() async {
// create scope using configuration
final scope = await scope.root([
MyConfigurable(),
]);
// resolve instances
final repository = scope.get<Repository>();
final appNotifier = scope.get<AppNotifier>();
}
- Implementers
Constructors
- Configurable(ConfigureScope configure)
-
Use
Configurable(...)
to create an inline configurable.constfactory -
Configurable.combine({required List<
Configurable> configurables}) -
Combine multiple
Configurable
s into oneConfigurable
.constfactory
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
-
configure(
ConfigurableScope scope) → FutureOr< void> -
configure
is used to configure scope synchronously or asynchronously. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited