Ref<T> class

Universal reference to any dependency - one type for all use cases

Examples:

final authRef = Ref<AuthService>();
final userRef = Ref<UserService>(tag: 'premium');
final scopedRef = Ref<CheckoutService>(scope: checkoutScope);

Constructors

Ref({String? tag, ZenScope? scope})
const

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope ZenScope?
final
tag String?
final

Methods

call() → T
Get the instance (throws if not found)
delete({bool force = false}) bool
Delete the instance
exists() bool
Check if instance exists
find() → T
Get the instance (throws if not found)
findOrNull() → T?
Find the instance (returns null if not found)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(T instance, {bool isPermanent = false}) → T
Register an eager instance
putLazy(T factory(), {bool isPermanent = false}) → void
Register a lazy factory
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override