navigateMultiple method

Future<List> navigateMultiple(
  1. List<RouteArgsPair> routeArgsPairs
)

Push multiple routes at the same time.

routeArgsPairs is a list of RouteArgsPair. Each RouteArgsPair contains the name of a route and its corresponding argument (if any).

Implementation

Future<List> navigateMultiple(
  List<RouteArgsPair> routeArgsPairs,
) {
  assert(routeArgsPairs.isNotEmpty);

  final pageResponses = <Future>[];

  // For each route check if it exists.
  // Push the route.
  routeArgsPairs.forEach((routeArgs) {
    _checkAndThrowRouteNotFound(
      routeArgs.name,
      routeArgs.args,
      NavigationType.push,
    );

    final response = _navigate(
        routeArgs.name,
        routeArgs.args,
        NavigationType.push,
        null,
        null,
        routeArgs.pageTransition,
        routeArgs.pageTransitionSettings);

    pageResponses.add(response);
  });

  return Future.wait(pageResponses);
}