replaceNamed<T> method

Future<T?> replaceNamed<T>(
  1. String name, {
  2. Map<String, String> pathParameters = const <String, String>{},
  3. Map<String, dynamic> queryParameters = const <String, dynamic>{},
  4. Object? extra,
})

Replaces the top-most page with the named route and optional parameters, preserving the page key.

This will preserve the state and not run any page animation. Optional parameters can be providded to the named route, e.g. name='person', pathParameters={'fid': 'f2', 'pid': 'p1'}.

See also:

  • pushNamed which pushes the given location onto the page stack.
  • pushReplacementNamed which replaces the top-most page of the page stack but always uses a new page key.

Implementation

Future<T?> replaceNamed<T>(
  String name, {
  Map<String, String> pathParameters = const <String, String>{},
  Map<String, dynamic> queryParameters = const <String, dynamic>{},
  Object? extra,
}) {
  return replace(
    namedLocation(name,
        pathParameters: pathParameters, queryParameters: queryParameters),
    extra: extra,
  );
}