pages method
Return the pages by building them from the appRouteDataList This function also verify the guards and if some patterns apply then it will get the pages by calling the guard() function
Implementation
List<AppPage> pages() {
// Get last app route data in order to check its path with the guard
AppRouteData? lastAppRouteData = appRouteDataList.isNotEmpty ? appRouteDataList.last : null;
List<AppPage> result = [];
if (lastAppRouteData == null) {
return [];
} else {
String path = lastAppRouteData.path;
for (AppNavigationGuard guard in guards) {
if (guard.shouldGuard(path)) {
AppLocation? location = guard.guard(path);
if (location != null) {
result = location.buildPages(path, lastAppRouteData.params);
if (lastAppRouteData.path != location.getRoute()) {
appRouteDataList.add(AppRouteData(path: location.getRoute(), pages: result, params: lastAppRouteData.params));
}
//todo logging
developer.log("pages (from location): ${result.toString()}", name: 'AbstractAppNavigationManager::pages');
return result;
} else {
break;
}
}
}
}
result = appRouteDataList.fold<List<AppPage>>([], (List<AppPage> list, AppRouteData routeData) {
return list..addAll(routeData.pages);
});
//todo logging
developer.log("pages (from app route): ${result.toString()}", name: 'AbstractAppNavigationManager::pages');
return result;
}