lazyReplace<P> static method

Future<void> lazyReplace<P>(
  1. InstanceBuilderCallback<P> builder, {
  2. String? tag,
  3. bool? fenix,
})

Lazily replaces the specified child widget with a new one.

Implementation

static Future<void> lazyReplace<P>(
  InstanceBuilderCallback<P> builder, {
  String? tag,
  bool? fenix,
}) async {
  // Get instance info and determine if it should be permanent
  final info = Get.getInstanceInfo<P>(tag: tag);
  final permanent = info.isPermanent ?? false;

  // Delete existing instance and register the new lazy builder
  await delete<P>(tag: tag, force: permanent);
  Get.lazyPut(
    builder,
    tag: tag,
    fenix: switch (fenix) {
      null => permanent,
      var value => value
    }
  );
}