popRoute method
Router.backButtonDispatcher,系统返回按钮回调 返回 true 表示自己拦截,返回 false 则跟随系统导航返回
Implementation
@override
Future<bool> popRoute({
Object? result,
PopMode popMode = PopMode.History,
}) async {
//Returning false will cause the entire app to be popped.
print('handle system pop!!!');
final wasPopup = await handlePopupRoutes(result: result);
if (wasPopup) {
print(
'pop route, use Navigator.push(ModalRoute route), will user Navigator.pop()');
return true;
}
print('pop route, remove top route and notifyListeners');
///如果在单独运行的情况下,只剩余一个页面,那么就让系统消费
if (!_canPop() && !multiple) {
return false;
}
await pop(result);
return true;
}