replace<P> method

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

Replaces a registered dependency with a new one. P is the type of the dependency being replaced, and child is the new instance.

Implementation

void replace<P>(P child, {String? tag}) async {
  final InstanceInfo info = Get.getInstanceInfo<P>(tag: tag);
  final bool permanent = info.isPermanent ?? false;
  delete<P>(tag: tag, force: permanent);
  put(child, tag: tag, permanent: permanent);
}