Levit class

The primary entry point for orchestrating dependency injection and reactivity in Levit.

Levit provides a unified API for managing LevitController lifecycles, resolving dependencies via LevitScope, and working with reactive state.

Constructors

Levit()

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

captureStackTrace bool
Whether to capture stack traces on state changes.
getter/setter pair
enableWatchMonitoring bool
Whether to enable performance monitoring for all LxWorker instances.
getter/setter pair
registeredCount int
The total number of dependencies registered in the current active scope.
no setter
registeredKeys List<String>
A list of all registration keys (type + tag) in the current active scope.
no setter

Static Methods

addDependencyMiddleware(LevitScopeMiddleware middleware) → void
Adds a global middleware for receiving dependency injection events.
addStateMiddleware(LevitReactiveMiddleware middleware) → void
Adds a middleware to the list of active middlewares.
batch<R>(R callback()) → R
Executes callback in a synchronous batch.
batchAsync<R>(Future<R> callback()) Future<R>
Executes asynchronous callback in a batch.
clearStateMiddlewares() → void
Removes all active state middlewares.
containsStateMiddleware(LevitReactiveMiddleware middleware) bool
Checks if a particular state middleware is currently registered.
createScope(String name) LevitScope
Creates a new child scope branching from the current active scope.
delete<S>({dynamic key, String? tag, bool force = false}) bool
Removes the registration for S and disposes of the instance.
disableAutoLinking() → void
Disables the "Auto-Linking" feature.
enableAutoLinking() → void
Enables the "Auto-Linking" feature.
find<S>({dynamic key, String? tag}) → S
Resolves a dependency of type S or identified by key or tag.
findAsync<S>({dynamic key, String? tag}) Future<S>
Asynchronously resolves a dependency of type S or identified by key or tag.
findOrNull<S>({dynamic key, String? tag}) → S?
Retrieves the registered instance of type S, or returns null if not found.
findOrNullAsync<S>({dynamic key, String? tag}) Future<S?>
Asynchronously retrieves the registered instance of type S, or returns null.
isInstantiated<S>({dynamic key, String? tag}) bool
Whether type S has already been instantiated.
isRegistered<S>({dynamic key, String? tag}) bool
Whether type S is registered in the current or any parent scope.
lazyPut<S>(S builder(), {String? tag, bool permanent = false, bool isFactory = false}) → void
Registers a builder that will be executed only when the dependency is first requested.
lazyPutAsync<S>(Future<S> builder(), {String? tag, bool permanent = false, bool isFactory = false}) Future<S> Function()
Registers an asynchronous builder for lazy instantiation.
put<S>(S builder(), {String? tag, bool permanent = false}) → S
Instantiates and registers a dependency using a builder.
removeDependencyMiddleware(LevitScopeMiddleware middleware) → void
Removes a DI middleware.
removeStateMiddleware(LevitReactiveMiddleware middleware) → void
Removes a middleware from the list of active middlewares.
reset({bool force = false}) → void
Disposes of all non-permanent dependencies in the current scope.
runWithContext<T>(LxListenerContext context, T fn()) → T
The context is passed to LevitReactiveMiddleware.startedListening and LevitReactiveMiddleware.stoppedListening.
runWithoutStateMiddleware(void action()) → void
Executes action while temporarily bypassing all registered middlewares.