add<T> method

void add<T>(
  1. T factory(), {
  2. String? tag,
  3. bool lazy = false,
  4. bool singleton = true,
})

Register a service

Implementation

void add<T>(T Function() factory,
    {String? tag, bool lazy = false, bool singleton = true}) {
  _services[_key(T, tag)] = _Service<T>(
    factory: factory,
    singleton: singleton,
    instance: !singleton || lazy ? null : factory(),
  );
}