put<S> static method

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

Instantiates and registers a dependency using a builder.

The builder is executed immediately.

// Example usage:

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

Parameters:

  • builder: A function that creates the dependency instance.
  • tag: Optional unique identifier to allow multiple instances of the same type S.
  • permanent: If true, this instance survives a non-forced reset.

Returns the created instance of type S.

Implementation

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