updateDeclarativeRoutes method

void updateDeclarativeRoutes(
  1. List<PageRouteInfo> routes
)

Replaces the list of _pages with given routes result used by declarative routing widgets

Implementation

void updateDeclarativeRoutes(List<PageRouteInfo> routes) async {
  _pages.clear();
  final routesToPush = <RouteMatch>[];
  for (var route in routes) {
    var match = _matchOrReportFailure(route);
    if (match == null) {
      break;
    }
    if (match.guards.isNotEmpty) {
      throw FlutterError("Declarative routes can not have guards");
    }
    routesToPush.add(match);
    final data = _createRouteData(match, routeData);
    _pages.add(pageBuilder(data));
  }

  navigationHistory.onNewUrlState(
    UrlState.fromSegments(
      root.currentSegments,
      shouldReplace: current == routeData,
    ),
    notify: false,
  );
}