build2 method
Implementation
Widget build2(BuildContext context) {
// 通过AppRoute before hook更换当前最新的页面
if (replaceCurrentPageInfo != null) {
pageTrack.removeLast();
registerTrackIndex(replaceCurrentPageInfo!);
replaceCurrentPageInfo = null;
}
// 浏览器url跳转处理
if (appRoutePath.getJumpRoute() != null) {
String jumpRoute = appRoutePath.getJumpRoute()!;
var currentPageIndex = pageTrack.length - 1;
var currentRoute = pageTrackIndexMapRoute[currentPageIndex];
pushNewRoute(String route) {
final newPage = appRoutePath.getRoutePageByRoute(route);
registerTrackIndex(newPage);
}
// 大于路栈大于1,则当前的系统提供的url可能是回退或前进
if (pageTrack.length > 1) {
String preRoute = pageTrackIndexMapRoute[pageTrack.length - 2]!;
// 判定为回退操作路由
if (preRoute == currentRoute) {
pageTrack = pageTrack.sublist(0, preRoute.length - 2);
} else {
pushNewRoute(jumpRoute);
}
// 即不是前进或后退,又不是一样的路由,那主判定新页面路由
} else if (currentRoute != jumpRoute) {
pushNewRoute(jumpRoute);
}
appRoutePath.cleanJumpRoute();
}
return Navigator(
key: navigatorKey,
pages: pageTrack,
onPopPage: handlePopPage,
);
}