Binding class sealed

A declarative service registration used inside a Module.

The expected list type enables Dart's dot shorthand syntax:

final appModule = Module([
  .provide<Database>(DatabaseLive.new),
  .provide<UserRepository>(UserRepositoryLive.new),
]);

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceType Type
no setter

Methods

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

Static Methods

factory<T extends Object>(Function constructor, {ServiceKey<T>? key}) Binding
Register a service that is recreated on every resolution.
instance<T extends Object>(T value, {ServiceKey<T>? key}) Binding
Register an already-created service instance.
lazySingleton<T extends Object>(Function constructor, {ServiceKey<T>? key}) Binding
Register a service created on first use and reused afterwards.
provide<T extends Object>(Function constructor, {Lifetime lifetime = Lifetime.lazySingleton, ServiceKey<T>? key}) Binding
Register a constructor-backed service.
resource<T extends Object>({required ResourceAcquire<T> acquire, required ResourceRelease<T> release, ServiceKey<T>? key}) Binding
Register an asynchronously acquired, runtime-owned resource.
singleton<T extends Object>(Function constructor, {ServiceKey<T>? key}) Binding
Register a service created eagerly when the runtime starts.