Levit class

The central entry point for the Levit framework.

Levit unifies the capabilities of levit_scope (Dependency Injection) and levit_reactive (Reactivity) into a single, cohesive API. It manages controller lifecycles, configuration, and global middleware.

Use put to register dependencies and find to retrieve them.

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 monitor performance metrics for LxWorker.
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, {Object? token}) → void
Adds a global middleware for receiving dependency injection events.
addStateMiddleware(LevitReactiveMiddleware middleware, {Object? token}) → 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 an asynchronous callback in a batch.
bindExisting<Alias, Concrete extends Alias>({String? sourceTag, String? tag}) → void
Binds Alias to an existing local singleton Concrete.
clearStateMiddlewares() → void
Clears all registered state middlewares.
containsStateMiddleware(LevitReactiveMiddleware middleware) bool
Checks if middleware is currently registered.
createScope(String name) LevitScope
Creates a new child scope branching from the current active scope.
delete<S>({String? tag, bool force = false}) Future<bool>
Removes the registration for S and disposes of the instance.
disableAutoLinking() → void
Disables automatic linking.
enableAutoLinking() → void
Enables automatic linking of reactive state to resource-owner lifecycles.
find<S>({String? tag}) → S
Finds a registered instance of type S.
findAsync<S>({String? tag}) Future<S>
Asynchronously finds an instance of type S.
findOrNull<S>({String? tag}) → S?
Finds an instance of type S, or returns null if missing.
findOrNullAsync<S>({String? tag}) Future<S?>
Asynchronously finds an instance of type S, or returning null.
isInstantiated<S>({String? tag}) bool
Returns true if type S is already instantiated (not just pending lazy init).
isRegistered<S>({String? tag}) bool
Returns true if type S is registered.
lazyPut<S>(S builder(), {String? tag, bool permanent = false, bool isFactory = false}) → void
Registers a lazy dependency builder.
lazyPutAsync<S>(Future<S> builder(), {String? tag, bool permanent = false, bool isFactory = false}) Future<S> Function()
Registers an asynchronous lazy dependency builder.
put<S>(S builder(), {String? tag, bool permanent = false}) → S
Instantiates and registers a dependency.
removeDependencyMiddleware(LevitScopeMiddleware middleware) → void
Removes a DI middleware.
removeDependencyMiddlewareByToken(Object token) bool
Removes a DI middleware by token.
removeStateMiddleware(LevitReactiveMiddleware middleware) → void
Removes a middleware from the list of active middlewares.
removeStateMiddlewareByToken(Object token) bool
Removes a state middleware by token.
reset({bool force = false}) Future<void>
Disposes of all non-permanent dependencies in the current scope.
runInScope<R>(FutureOr<R> callback(), {String name = 'scoped_run', LevitScope? parentScope}) Future<R>
Runs callback in a fresh child scope and disposes it automatically.
runWithContext<T>(LxListenerContext context, T fn()) → T
Executes fn within a specific listener context.
runWithoutStateMiddleware(void action()) → void
Bypasses all state middlewares for the duration of action.