put<S> static method

S put<S>(
  1. S builder(), {
  2. String? tag,
  3. bool permanent = false,
})

Instantiates and registers a dependency in the active scope.

The builder is executed immediately.

// Example usage:

Ls.put(() => MyService());

Use tag to differentiate multiple instances of the same type. Set permanent to true to survive a non-forced reset only. Scope LevitScope.dispose always force-clears permanents. Prefer permanent on root / long-lived scopes.

Returns the created instance.

Implementation

static S put<S>(S Function() builder, {String? tag, bool permanent = false}) {
  return currentScope.put<S>(builder, tag: tag, permanent: permanent);
}