Ls class
The global entry point for accessing the LevitScope system.
Ls ("Levit Scope") acts as a static proxy to the currently active LevitScope. It uses Zone values to determine the current scope context, defaulting to the root scope if none is active.
// Example usage:
// Finds 'AuthService' in the current scope
final auth = Ls.find<AuthService>();
Constructors
- Ls()
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 → LevitScope
-
Returns the currently active LevitScope.
no setter
- registeredCount → int
-
The number of dependencies registered in the active scope.
no setter
-
registeredKeys
→ List<
String> -
A list of keys for all dependencies in the active scope.
no setter
- zoneScopeKey → Object
-
The Zone key used to identifying the active LevitScope.
final
Static Methods
-
addMiddleware(
LevitScopeMiddleware middleware, {Object? token}) → void - Adds a global middleware to intercept dependency injection events.
-
bindExisting<
Alias, Concrete extends Alias> ({String? sourceTag, String? tag}) → void -
Binds
Aliasto an existing local singletonConcrete. -
createScope(
String name) → LevitScope - Creates a child scope from the active scope.
-
delete<
S> ({String? tag, bool force = false}) → Future< bool> - Removes a dependency from the active scope.
-
find<
S> ({String? tag}) → S -
Finds a registered instance of type
Sin the active scope. -
findAsync<
S> ({String? tag}) → Future< S> -
Asynchronously finds a registered instance of type
Sin the active scope. -
findOrNull<
S> ({String? tag}) → S? -
Finds a registered instance of type
Sin the active scope, ornull. -
findOrNullAsync<
S> ({String? tag}) → Future< S?> -
Asynchronously finds a registered instance of type
S, or returnsnull. -
isInstantiated<
S> ({String? tag}) → bool -
Returns
trueif typeShas been instantiated in the active or parent scope. -
isRegistered<
S> ({String? tag}) → bool -
Returns
trueif typeSis registered in the active or any parent scope. -
lazyPut<
S> (S builder(), {String? tag, bool permanent = false, bool isFactory = false}) → void - Registers a lazy dependency in the active scope.
-
lazyPutAsync<
S> (Future< S> builder(), {String? tag, bool permanent = false, bool isFactory = false}) → Future<S> Function() - Registers an asynchronous dependency in the active scope.
-
put<
S> (S builder(), {String? tag, bool permanent = false}) → S - Instantiates and registers a dependency in the active scope.
-
removeMiddleware(
LevitScopeMiddleware middleware) → void - Removes a global middleware.
-
removeMiddlewareByToken(
Object token) → bool -
Removes a global middleware by
token. -
reset(
{bool force = false}) → Future< void> - Disposes all non-permanent dependencies in the active scope.