ConfigurableScope class abstract

ConfigurableScope is a draft of scope that can be configured with scope.expose and scope.addDispose methods, it is often used during scope creation.

Normal Scope can not been configured after creation.

Not Feasible:

final Scope rootScope = await Scope.root([]);

final repository = Repository();
rootScope.expose<Repository>( // Error: 'scope.expose' isn't defined
  expose: () => repository
);

It's recommended to configure scope during creation via ConfigurableScope.

Feasible:

final Scope rootScope = await Scope.root([
  Configurable((ConfigurableScope scope) {
    final repository = Repository();
    scope.expose<Repository>( // works as expected
      expose: () => repository
    );
  })
]);
Implemented types
Available Extensions

Constructors

ConfigurableScope()
factory

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

addDisposable(Disposable disposable) → void
add a disposable to current sink.
inherited
addDisposables(List<Disposable> disposables) → void
add a list of disposable to current sink.
inherited
dispose() → void
As opposite to scope.push, scope can also be disposed/popped. We can register dispose logic, that will run when scope been disposed:
inherited
expose<T>({Object? name, required Getter<T> expose}) → void
Use scope.expose<T>(...) to expose instance within current scope, this instance can be resolved later:
inherited
getOrNull<T>({Object? name}) → T?
Use scope.getOrNull<T>(...) to safely resolve instance. This method will return null when instance is not exposed:
inherited
has<T>({Object? name}) bool
Use scope.has<T>(...) to check if instance has been exposed:
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
push(List<Configurable> configure) FutureOr<Scope>
Use scope.push(...) to create a new child scope. Child scope inherited getters from parent:
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited