replace<P> method
Replaces an existing registered instance of type P with a new child instance.
If the existing instance is permanent, it will be forcefully deleted first before the new child is registered.
tagOptional tag to identify the instance.
Implementation
void replace<P>(P child, {String? tag}) {
final info = getInstanceInfo<P>(tag: tag);
final permanent = (info.isPermanent ?? false);
delete<P>(tag: tag, force: permanent);
put(child, tag: tag, permanent: permanent);
}