withConfig<T> method

  1. @nonVirtual
Factory<T> withConfig<T>(
  1. ConfigBuilder<T, TConfig> builder, {
  2. bool singleton = true,
})

Registers a singleton builder for an object that requires configuration values

Implementation

@nonVirtual
Factory<T> withConfig<T>(
  ConfigBuilder<T, TConfig> builder, {
  bool singleton = true,
}) {
  final config = injector.get<TConfig>();
  return singleton
      ? Factory.singleton(() => builder(config))
      : Factory.provider(() => builder(config));
}