ZenScope class
Dependency scoping mechanism for hierarchical access to dependencies Clean core implementation - debugging utilities moved to debug package
Constructors
- ZenScope.new({ZenScope? parent, String? name, String? id})
- Creates a new scope
Properties
-
childScopes
→ List<
ZenScope> -
Get all child scopes (immutable view)
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
final
- isDisposed → bool
-
Check if scope is disposed
no setter
- name → String?
-
final
- parent → ZenScope?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearAll(
{bool force = false}) → void - Clear all dependencies from this scope
-
contains<
T> ({String? tag}) → bool - Checks if a type is registered (either as an instance or a factory)
-
containsInstance(
dynamic instance) → bool - Check if instance exists in this scope hierarchy
-
createChild(
{String? name}) → ZenScope - Create a child scope from this scope
-
delete<
T> ({String? tag, bool force = false}) → bool - Delete a dependency by type and optional tag
-
deleteByTag(
String tag, {bool force = false}) → bool - Delete a dependency by tag only (without knowing the type)
-
deleteByType(
Type type, {bool force = false}) → bool - Delete a dependency by runtime type only
-
dispose(
) → void - Dispose this scope and all its dependencies
-
exists<
T> ({String? tag}) → bool - Check if a dependency exists
-
find<
T> ({String? tag}) → T? - Find a dependency by type and optional tag (searches hierarchy)
-
findAllOfType<
T> () → List< T> - Find all instances of a given type in this scope and child scopes
-
findInThisScope<
T> ({String? tag}) → T? - Find a dependency only in this specific scope (not in parents)
-
findRequired<
T> ({String? tag}) → T - Find a dependency (throws if not found)
-
forceCompleteReset(
) → void - Force complete reset of scope internal state (for rollback)
-
getAllDependencies(
) → List - Get all dependencies in this scope (for debugging)
-
getTagForInstance(
dynamic instance) → String? - Get a tag for a specific instance if it exists
-
isPermanent(
{required Type type, String? tag}) → bool - Check if a dependency is permanent
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put<
T> (T instance, {String? tag, bool? isPermanent}) → T - Register a dependency in this scope
-
putFactory<
T> (T factory(), {String? tag}) → void - Register a factory that creates new instances each time
-
putLazy<
T> (T factory(), {String? tag, bool isPermanent = false}) → void - Register a lazy singleton factory
-
registerDisposer(
void disposer()) → void - Register a function that will be called when this scope is disposed
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited