replace<P> method

void replace<P>(
  1. P child, {
  2. String? tag,
})

Replace a parent instance of a class in dependency management with a child instance

  • tag optional, if you use a tag to register the Instance.

Implementation

void replace<P>(P child, {String? tag}) {
  final info = getInstanceInfo<P>(tag: tag);
  final permanent = (info.isPermanent ?? false);
  final factory = _typeSingl[P]?[tag];
  if (factory != null) {
    _deleteFactory(factory, force: permanent, keepFactory: false);
  }
  put<P>(child, tag: tag, permanent: permanent);
}