lazyPut<S> method

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

Registers a builder that will be executed only when the dependency is first requested.

Implementation

void lazyPut<S>(
  S Function() builder, {
  String? tag,
  bool permanent = false,
  bool isFactory = false,
}) {
  final scope = _ScopeProvider.of(_context);
  if (scope != null) {
    scope.lazyPut<S>(
      builder,
      tag: tag,
      permanent: permanent,
      isFactory: isFactory,
    );
  } else {
    Levit.lazyPut<S>(
      builder,
      tag: tag,
      permanent: permanent,
      isFactory: isFactory,
    );
  }
}