pushNamed method
Future<void>
pushNamed({
- required String name,
- ResultCallBack? onResult,
- Object? arguments,
- Widget? emptyPage,
- bool custom = true,
- String? restorationId,
- LaunchMode launchMode = LaunchMode.standard,
根据名称跳转页面
Implementation
Future<void> pushNamed(
{required String name,
ResultCallBack? onResult,
Object? arguments,
Widget? emptyPage,
bool custom = true,
String? restorationId,
LaunchMode launchMode = LaunchMode.standard}) async {
// 执行路由守卫检查
final from = RouteInformation(uri: Uri.parse(_location ?? '/'));
final to = RouteInformation(uri: Uri.parse(name));
final canNavigate = await _checkRouteGuards(from, to);
if (!canNavigate) {
return;
}
var page = pageMap?[name];
_location = name;
if (custom && page == null) {
page = _routePathCallBack
?.call(RouteInformation(uri: Uri.parse(_location!)));
}
if (page == null) {
_location = '404';
page = emptyPage ?? _notFoundPage ?? const EmptyPage();
}
push(
page: page,
name: name,
onResult: onResult,
arguments: arguments,
restorationId: restorationId,
launchMode: launchMode);
}