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.
Registrations that delete intentionally keeps alive (a fenix
factory kept for resurrection, a GetxService, or an entry whose
lateRemove disposal is still pending) are evicted outright, so the
new child always takes their place.
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);
_evictSurvivingRegistration(_getKey(P, tag));
put(child, tag: tag, permanent: permanent);
}