RouterProxy class

Inheritance
Mixed-in types

Properties

currentConfiguration RouteInformation
Called by the Router when it detects a route information may have changed as a result of rebuild.
no setteroverride
currentTargetPage ValueNotifier<Widget?>
通知特定的页面 ValueListenableBuilder(仅用于主路由栈)
getter/setter pair
drawerConfig DrawerConfig?
获取当前抽屉配置(仅抽屉路由栈可用)
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isDrawerStack bool
是否为抽屉路由栈
final
isDrawerStackOpen bool
检查抽屉是否打开(仅抽屉路由栈可用)
no setter
isMainStack bool
是否为主路由栈
final
location String
no getter
The key used for retrieving the current navigator.
no setteroverride
pageMap Map?
静态路由的页面
getter/setter pair
pages List<MaterialPage>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackId String
路由栈标识
final

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addPageTypeGuard(PageTypeGuard guard) → void
添加页面类型守卫 用于 push(page: xxx) 方式的导航守卫 守卫会在路由跳转前执行,返回true允许跳转,false拦截跳转
addRouteGuard(RouteGuard guard) → void
添加路由守卫 守卫会在路由跳转前执行,返回true允许跳转,false拦截跳转
backTarget() → void
返回到上一个非页面跳转的目标
bindDrawerContext(BuildContext context) → void
绑定抽屉上下文(仅抽屉路由栈可用)
build(BuildContext context) Widget
Called by the Router to obtain the widget tree that represents the current state.
override
canPop() bool
检查页面栈是否可以pop
clearPageTypeGuards() → void
清空所有页面类型守卫
clearRouteGuards() → void
清空所有路由守卫
clearTargets() → void
清空所有非页面跳转的目标
closeDrawerStack() → void
关闭抽屉(仅抽屉路由栈可用)
closeMainDrawer({bool isEndDrawer = false}) → void
关闭主页面的抽屉(主路由栈可用)
configureDrawer(DrawerConfig config) → void
配置抽屉行为(仅抽屉路由栈可用)
defaultParser() CustomParser
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
getArguments<T>() → T?
获取当前显示页面的参数
getCurrentMaterialPage() MaterialPage
获取当前显示页面的MaterialPage对象,可用于获取参数
getCurrentPage() Widget
获取当前显示的页面Widget
getLocation() String?
goRootPage() → void
回到根页面
goToTarget(Widget page, {bool insert = true}) → void
非页面跳转,只切换到目标页面 (例如主页的Tab切换)
isMainDrawerOpen({bool isEndDrawer = false}) bool
检查主页面的抽屉是否打开(主路由栈可用)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
notifyListeners() → void
Call all the registered listeners.
inherited
openDrawerStack() → void
打开抽屉(仅抽屉路由栈可用)
openMainDrawer({bool isEndDrawer = false}) → void
打开主页面的抽屉(主路由栈可用)
pop<T>([T? result]) → void
popAndPushNamed({required String name, Object? arguments, Widget? emptyPage}) → void
pop当前页面,然后push一个新页面
popRoute() Future<bool>
Called by the Router when the Router.backButtonDispatcher reports that the operating system is requesting that the current route be popped.
override
popWithResult<T>([T? result]) → void
关闭当前窗口,并附带返回值 示例: RouterProxy.getInstance().popWithResult('从页面返回的数据');
push<T>({required Widget page, ResultCallBack? onResult, String? name, Object? arguments, String? restorationId, bool maintainState = true, bool fullscreenDialog = false, bool allowSnapshotting = true, LaunchMode launchMode = LaunchMode.standard}) Future<void>
推出一个新页面到导航栈
pushAndRemoveAll(Widget page) → void
清空页面栈并push新页面
pushNamed({required String name, ResultCallBack? onResult, Object? arguments, Widget? emptyPage, bool custom = true, String? restorationId, LaunchMode launchMode = LaunchMode.standard}) Future<void>
根据名称跳转页面
pushNamedAndRemoveAll({required String name, Object? arguments, Widget? emptyPage, String? restorationId}) → void
跳转到指定页面,并清空之前的所有页面
pushStackTop({required Widget page}) → void
将页面置于栈顶(如果已存在则先移除)
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removePageTypeGuard(PageTypeGuard guard) → void
移除页面类型守卫
removeRouteGuard(RouteGuard guard) → void
移除路由守卫
replace({required Widget page, String? name, Object? arguments, String? restorationId}) → void
替换当前页面
setInitialRoutePath(RouteInformation configuration) Future<void>
Called by the Router at startup with the structure that the RouteInformationParser obtained from parsing the initial route.
inherited
setNewRoutePath(RouteInformation configuration) Future<void>
Called by the Router when the Router.routeInformationProvider reports that a new route has been pushed to the application by the operating system.
override
setRestoredRoutePath(RouteInformation configuration) Future<void>
Called by the Router during state restoration.
inherited
showAppBottomSheet<T>({required WidgetBuilder builder, bool isScrollControlled = false, Color? backgroundColor, double? elevation, ShapeBorder? shape, Clip? clipBehavior, BoxConstraints? constraints, Color? barrierColor, bool useRootNavigator = false, bool isDismissible = true, bool enableDrag = true, RouteSettings? routeSettings, AnimationController? transitionAnimationController, Offset? anchorPoint}) Future<T?>
显示一个通用的模态底部面板(Modal Bottom Sheet) 示例: RouterProxy.getInstance().showAppBottomSheet( builder: (context) => Container( height: 200, child: Center(child: Text('这是一个底部面板')), ), );
showAppDialog<T>({required WidgetBuilder builder, bool barrierDismissible = true, Color? barrierColor = Colors.black54, String? barrierLabel, bool useSafeArea = true, bool useRootNavigator = true, RouteSettings? routeSettings, Offset? anchorPoint}) Future<T?>
显示一个通用的对话框(Dialog) 示例: RouterProxy.getInstance().showAppDialog( builder: (context) => AlertDialog( title: Text('提示'), content: Text('这是一个通过路由服务显示的对话框。'), actions:
showAppSnackBar({required String message}) → void
显示一个提示条(SnackBar) 示例: RouterProxy.getInstance().showAppSnackBar(message: '这是一个提示!');
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getAllDrawerInstances() Map<String, RouterProxy>
获取所有抽屉路由实例
getDrawerInstance({required String stackId, Map? pageMap, DrawerConfig? drawerConfig}) RouterProxy
获取抽屉路由实例(多实例)
getInstance({RoutePathCallBack? routePathCallBack, ExitWindow? exitWindow, NavigateToTargetCallBack? navigateToTargetCallBack, Map? pageMap, Widget? notFoundPage}) RouterProxy
获取主路由实例(单例)
removeDrawerInstance(String stackId) → void
移除抽屉路由实例