updatePage method
void
updatePage(
- RouteState newState, {
- bool notif = true,
- bool addOne = false,
- bool fromLast = false,
add new page in stack by new RouteState notif - use notifyListeners addOne - return when added one page from routes config fromLast - foreach config from last route
Implementation
void updatePage(RouteState newState,
{bool notif = true, bool addOne = false, bool fromLast = false}) {
l.log(
// ignore: lines_longer_than_80_chars
'updatePage: newState= $newState, notif = $notif , addOne = $addOne , fromLast = $fromLast',
name: debugLabel);
l.log('pages $pages', name: debugLabel);
var findedPage = false;
final configs = [...routes, initialRoute];
final routesList = fromLast ? configs : configs.reversed.toList();
for (final item in routesList) {
final newStateWithoutPrefix = newState.diff(nestedPrefixPath);
l.log('newStateWithoutPrefix $newStateWithoutPrefix', name: debugLabel);
final isThisPage = item.isThisPage(newStateWithoutPrefix);
if (isThisPage) {
l.log('add page ${item.state(newState.uri)}', name: debugLabel);
previousState.add(RouteState(
uri: item.state(newState.uri).uri,
uriState: newState.uriState,
innerState: newState.innerState,
));
currentState = RouteState(
uri: newState.uri,
uriState: newState.uriState,
innerState: newState.innerState,
);
pages!.add(item.page(state: newState));
findedPage = true;
if (notif == true) {
notifyListeners();
}
if (addOne == true) {
return;
}
}
}
if (findedPage == false) {
previousState.add(currentState);
currentState = RouteState(uri: newState.uri, uriState: newState.uriState);
pages!.add(onUnknownRoute.page());
}
if (notif == true) {
notifyListeners();
}
}