-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
I have a question about navigation. On instagram in iOS, however you go deep in a tab, when you click the tab you will have one pop action back to your main screen for that tab. I tried popUntil but it shows continues pops.
I implemented a function that does what I want. Before submitting it as a PR to flutter, I want to check if there is another solution for this. And here's the function I created:
/// In flutter/lib/src/widgets/navigator.dart
/// Calls [pop] to `position` after removing all routes between the position and the last.
void popToFirst(int position) {
assert(_history.isNotEmpty);
if (_history.length > position) {
final List<Route<dynamic>> routes =
_history.sublist(position, _history.length - 1);
routes.forEach(removeRoute);
pop();
}
}Metadata
Metadata
Assignees
Labels
f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.