pushAll method
Adds the corresponding pages to given routeInfos list to the _steps
stack at once
Similar to AutoRoute's pushAll method
Implementation
void pushAll(List<NavRouteInfo> routeInfos) {
try {
final context = _currentContext;
if (context == null) {
if (_enableLogger) {
debugPrint('NavService.pushAll: No valid context found.');
}
return;
}
if (routeInfos.isEmpty) {
if (_enableLogger) {
debugPrint('NavService.pushAll: No routeInfos provided.');
}
return;
}
final navigator = Navigator.of(context);
// Push all routes sequentially
for (int i = 0; i < routeInfos.length; i++) {
final routeInfo = routeInfos[i];
final route = _routes[routeInfo.path];
if (route != null) {
final navExtra = NavExtra(routeInfo.extra ?? {});
if (i == routeInfos.length - 1) {
// Last route with animation
navigator.push(
_buildPageRoute<dynamic>(
path: routeInfo.path,
extra: navExtra,
route: route,
),
);
} else {
// Other routes without push animation but with pop animation
navigator.push(
_buildPageRouteNoPushAnimation(
path: routeInfo.path,
extra: navExtra,
route: route,
),
);
}
} else {
if (_enableLogger) {
debugPrint(
'NavService.pushAll: Route not found for path: ${routeInfo.path}',
);
}
}
}
// ignore: avoid_catches_without_on_clauses
} catch (e, st) {
if (_enableLogger) {
debugPrint('NavService.pushAll.exception: $e\n$st');
}
}
}