AgLocator class

A minimal, dependency-free service locator.

AG only ever needs three things from a DI container: register an eagerly-created singleton (put), register a lazily-created one (lazyPut), and resolve it later by type (find). No tags and no fenix — this framework has never needed them.

Route scopes. What an AgBinding registers while its route is pushed lives in that route's own AgScope, not in the global registry, so /product/7 and /product/9 on the stack at once each get their own Service, Repo and Controller. A page resolves its route's scope directly; any other find looks in the global registry, then in the live route scopes, most recent first.

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

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

delete<T extends Object>() → void
Removes T's global registration entirely (both a realized instance and any still-pending factory), disposing it first if it's disposable — a no-op if T was registered permanent. A route scope's registrations are released with its route.
deleteByType(Type type) → void
delete's non-generic equivalent, for callers that only have a Type value in hand.
find<T extends Object>() → T
Resolves the singleton for T — realizing it from a pending lazyPut factory if this is the first access. Throws StateError if nothing was ever registered for T.
lazyPut<T extends Object>(T factory()) → void
Registers factory to create T's singleton the first time it's resolved via find — never before.
put<T extends Object>(T instance, {bool permanent = false}) → void
Registers instance as the singleton for T, created eagerly.
reset() → void
Test-only: clears every registration, including permanent ones and live route scopes, disposing each realized ChangeNotifier.