back method
Implementation
Future<bool> back(dynamic until, {bool force = false}) async {
bool ok = true;
// determine number of pages to go back
int? pages;
if (until is int) pages = until;
if (until is String) {
// match by index
if (until.startsWith('[') && until.endsWith(']')) {
int? pageIndex = toInt(until.substring(1, until.length - 1));
pages = pageIndex != null ? (_pages.length) - pageIndex : -1;
}
// match by name
else {
if (!until.startsWith("/")) until = "/$until";
Page? page = _pages.lastWhereOrNull((page) {
// make sure we leave args off for the comparison
String name = page.name ?? '';
return name.split('?')[0] == until;
});
if ((page != null) && (_pages.last != page)) {
pages = _pages.length - _pages.indexOf(page) - 1;
}
}
}
// go back
if (pages != null) {
ok = await _goback(pages, force: force);
}
return ok;
}