setupRoutes method

void setupRoutes(
  1. List<PageRouteInfo> routes
)

Implementation

void setupRoutes(List<PageRouteInfo> routes) {
  final routesToPush = _matchAllOrReportFailure(routes)!;
  if (_routeData.hasPendingChildren) {
    final preMatchedRoute = _routeData.pendingChildren.last;
    final correspondingRouteIndex = routes.indexWhere(
      (r) => r.routeName == preMatchedRoute.name,
    );
    if (correspondingRouteIndex != -1) {
      routesToPush[correspondingRouteIndex] = preMatchedRoute;
      _previousIndex = _activeIndex;
      _activeIndex = correspondingRouteIndex;
    }
  }

  if (routesToPush.isNotEmpty) {
    _pushAll(routesToPush);
  }
  _routeData.pendingChildren.clear();
}