replace method

void replace(
  1. String path, {
  2. String? id,
})

Replace the current route by a new one by path.

id is used to match listeners.

Process route middlewares before replace.

Implementation

void replace(String path, {String? id}) {
  final routeDefinition = _findRouteDefinition(path);

  _processMiddlewares(
    routeDefinition,
    (RouteDefinition routeDefinition) {
      final page =
          PageWrapper(routeDefinition, path, _nextRouteIndex, id: id);
      final oldPage = _pageStack.removeLast();
      _pageStack.add(page);
      notifyListeners();
      _notifyReplace(page, oldPage);
    },
  );
}