popUntil method
pop 到指定页面并替换当前页面
@param routeName 要pod到的页面,如果对应routeName的路由不存在会pop到上一个页面 @param isFarthest 是否pop到最远端的routeName,默认isFarthest = false表示最近的,isFarthest = true表示最远的
Implementation
@override
Future<void> popUntil(String routeName, {bool isFarthest = false}) async {
if (navigatorObserver.routeExists(routeName) && rootContext.mounted) {
if (isFarthest) {
for (Route<dynamic> route in navigatorObserver.routeStack) {
if (route.settings.name == routeName) {
Navigator.of(rootContext).popUntil((r) => r == route);
break;
}
}
return;
} else {
return Navigator.popUntil(
rootContext,
ModalRoute.withName(
routeName,
),
);
}
} else {
return await pop();
}
}