lazyPut<S> static method

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

Registers a lazy dependency in the active scope.

The builder is executed only when the dependency is first requested.

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. Set isFactory to true to create a new instance every time find is called.

Implementation

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