replace<T> method

Future<T?> replace<T>(
  1. String location, {
  2. Object? extra,
})

Replaces the top-most page of the page stack with the given one but treats it as the same page.

Implementation

Future<T?> replace<T>(String location, {Object? extra}) async
//  => App.goRouter?.replace<T>(location, extra: extra) ?? Future.value();
{
  T? result;
  final router = App.goRouter;
  if (router == null) {
    result = await Navigator.pushReplacementNamed<T, T>(
      this,
      location,
      arguments: extra,
    );
  } else {
    result = await router.replace<T>(location, extra: extra);
  }
  return result;
}