Zen class

Main Zenify API for dependency injection

Provides a clean, simple API for global dependency management. For hierarchical scopes, use ZenRoute or ZenScopeWidget directly.

Available extensions

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 Properties

currentScope ZenScope
Get the current active scope (for internal use)
no setter
queryCache ZenQueryCache
Shorthand for ZenQueryCache.instance.
no setter
rootScope ZenScope
Get the root scope for global dependencies
no setter

Static Methods

clearQueryCache() → void
Clear the query cache
createScope({String? name, ZenScope? parent}) ZenScope
Create a new scope for isolated dependencies
delete<T>({String? tag, bool force = false}) bool
Delete a dependency from root scope
deleteAll({bool force = false}) → void
Delete all dependencies from root scope
exists<T>({String? tag}) bool
Check if a dependency exists in root scope
find<T>({String? tag}) → T
Find a dependency in root scope (throws if not found)
findOrNull<T>({String? tag}) → T?
Find a dependency in root scope (returns null if not found)
get<T>({String? tag}) → T
Alias for find. Gets a dependency from the container.
getAllModules() Map<String, ZenModule>
Get all registered modules
getModule(String name) ZenModule?
Get a registered module by name
has<T>({String? tag}) bool
Alias for exists. Checks if a dependency exists in the container.
hasModule(String name) bool
Check if a module is registered
init({ZenStorage? storage, Map<String, ZenMutationHandler>? mutationHandlers}) Future<void>
Initialize Zenify - call once at app startup
put<T>(T instance, {String? tag, bool? isPermanent}) → T
Register a dependency in root scope
putLazy<T>(T factory(), {String? tag, bool isPermanent = false, bool alwaysNew = false}) → void
Register a lazy factory in root scope
registerModules(List<ZenModule> modules, {ZenScope? scope}) Future<void>
Register and load modules with auto-dependency resolution
remove<T>({String? tag, bool force = false}) bool
Alias for delete. Removes a dependency from the container.
reset() → void
Complete reset - clear everything (for testing)
resetCurrentScope() → void
Reset current scope to root
setCurrentScope(ZenScope scope) → void
Set current scope (used by routing/navigation)
setNetworkStream(Stream<bool> stream) → void
Set a stream to monitor network connectivity status.
testMode() ZenTestMode
Enter test mode for easy mocking