ZenScope class

Dependency scoping mechanism for hierarchical access to dependencies Clean core implementation - debugging utilities moved to debug package

Available extensions

Constructors

ZenScope({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 = false}) → T
Register a dependency in this scope
putCachedQuery<T>({required Object queryKey, required ZenQueryFetcher<T> fetcher, Duration staleTime = const Duration(minutes: 5), T? initialData}) ZenQuery<T>

Available on ZenScope, provided by the ZenScopeQueryExtension extension

Register a scoped query with common caching defaults.
putLazy<T>(T factory(), {String? tag, bool isPermanent = false, bool alwaysNew = false}) → void
Register a lazy factory
putQuery<T>({required Object queryKey, required ZenQueryFetcher<T> fetcher, ZenQueryConfig? config, T? initialData}) ZenQuery<T>

Available on ZenScope, provided by the ZenScopeQueryExtension extension

Register a scoped query with automatic lifecycle management.
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