Navigator - removeUri
carmas123 opened this issue · comments
Massimo Caroccia commented
Hi, the removeUri method of VxNavigator must find the latest index into the stack and not the first:
No we have this method into the code:
/// remove a specific [Uri] and the corresponding [Page]
void removeUri(Uri uri) {
final index = _uris.indexOf(uri);
if (index != -1) {
final page = _pages.removeAt(index);
final uri = _uris.removeAt(index);
if (kIsWeb) {
VxNav.replaceUrl(uri);
}
if (observers != null) {
for (final observer in observers!) {
observer.didChangeRoute(uri, page, "pop");
}
}
notifyListeners();
}
}
it could be:
/// remove a specific [Uri] and the corresponding [Page]
void removeUri(Uri uri) {
final index = _uris.lastIndexOf(uri); <--- CHANGE HERE
if (index != -1) {
final page = _pages.removeAt(index);
final uri = _uris.removeAt(index);
if (kIsWeb) {
VxNav.replaceUrl(uri);
}
if (observers != null) {
for (final observer in observers!) {
observer.didChangeRoute(uri, page, "pop");
}
}
notifyListeners();
}
}
This because into a long stack we can have also the same uri into the stack and usually we need to remove the last page from the stack and not the first stacked element.
Regards.