Container class
A simple service container.
Constructors
- Container({String? debugName})
-
Always returns a singleton representing the only container to be alive.
factory
- Container.scoped([String? debugName])
- Creates a scoped container.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialized → bool
-
no setter
- log ↔ Logger
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- silent ↔ bool
-
Whether ignoring assertion errors in the following cases:
getter/setter pair
Methods
-
call<
T> ([String? name]) → T? -
Attempts to resolve the type
T
. -
clear(
) → Future - Removes all instances and builders from the container.
-
forEachProvider(
void onEach(String type, _Provider provider)) → void -
initializeEagerSingletons(
) → Future -
Initializes any singletons that are flagged
eagerInit
=true, so you don't have to manually instantiate them. -
instance<
T> ({String? name, bool autoRegister = false}) → Instance? -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerFactory<
S, T extends S> (Factory< S> factory, {String? name, bool? isSilent}) → void - Registers a factory into the container.
-
registerInstance<
S, T extends S?> (T instance, {String? name, bool? isSilent}) → void - Registers an instance into the container.
-
registerSingleton<
S, T extends S> (Factory< S> factory, {String? name, bool eagerInit = false, bool? isSilent}) → void - Registers a factory that will be called only only when accessing it for the first time, into the container.
-
resolve<
T> ({String? name, bool autoRegister = false}) → T? -
searchForImplementation<
T> ([String? name]) → T? -
Searches existing instances that have been previously registered to find
one that implements
T
-
toString(
) → String -
A string representation of this object.
inherited
-
tryInstance<
T> ({String? name, bool autoRegister = false}) → Instance? -
unregister<
T> ({String? name, bool? isSilent}) → Future -
Removes the entry previously registered for the type
T
.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited