pop method
- String? page
Removes the last route in the routes history.
If routes contain only one record, then removes segments of that record
by /
if any, otherwise replaces it with Routes.home.
Implementation
void pop([String? page]) {
if (_accounted.remove(page ?? routes.lastOrNull)) {
return;
}
if (routes.isNotEmpty) {
if (page != null && !routes.contains(page)) {
return;
}
if (routes.length == 1) {
final String split = routes.last.split('/').last;
String last = routes.last.replaceFirst('/$split', '');
if (last == '' ||
(_auth.status.value.isSuccess && last == Routes.work) ||
last == Routes.contacts ||
last == Routes.chats ||
last == Routes.menu ||
last == Routes.user) {
last = Routes.home;
}
_accounted.remove(routes.last);
routes.last = last;
} else {
if (page != null) {
routes.remove(page);
} else {
_accounted.remove(routes.last);
routes.removeLast();
}
if (routes.isEmpty) {
routes.add(Routes.home);
}
}
notifyListeners();
}
}