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
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<String, Widget>
静态路由的页面
getter/setter pair
pages → List<MaterialPage<Object?>>
no setter
routeInformationParser → RouteInformationParser<RouteInformation>
当前使用的路由解析器。
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拦截跳转
bindDrawerContext(BuildContext context) → void
绑定抽屉上下文(仅抽屉路由栈可用)
bindMainScaffoldKey(GlobalKey<ScaffoldState> scaffoldKey) → void
Explicitly binds the ScaffoldState used by main drawer helpers.
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
清空所有路由守卫
closeDrawerStack() → void
关闭抽屉(仅抽屉路由栈可用)
closeMainDrawer({bool isEndDrawer = false}) → void
关闭主页面的抽屉(主路由栈可用)
configureDrawer(DrawerConfig config) → void
配置抽屉行为(仅抽屉路由栈可用)
defaultParser() → RouteInformationParser<RouteInformation>
dispose() → void
释放路由实例持有的页面栈、上下文和静态引用。
override
getArguments<T>() → T?
获取当前显示页面的参数
getCurrentMaterialPage() → MaterialPage<Object?>
获取当前显示页面的MaterialPage对象,可用于获取参数
getCurrentPage() → Widget
获取当前显示的页面Widget
getLocation() → String?
goRootPage() → Future<void>
回到根页面
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([Object? result]) → void
popAndPushNamed({required String name, Object? arguments, Widget? emptyPage}) → Future<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([Object? result]) → void
关闭当前窗口,并附带返回值 示例: RouterProxy.getInstance().popWithResult('从页面返回的数据');
push({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, {String? name, Object? arguments, String? restorationId}) → Future<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}) → Future<void>
跳转到指定页面,并清空之前的所有页面
pushStackTop({required Widget page}) → Future<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}) → Future<void>
替换当前页面
resetForTesting() → 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
setRouteInformationParser(RouteInformationParser<RouteInformation> parser) → void
设置与 MaterialApp.router 共享的路由解析器。
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 Properties

debugLogging ↔ bool
是否输出调试日志。release 下默认关闭,避免泄露路由信息。
getter/setter pair

Static Methods

getAllDrawerInstances() → Map<String, RouterProxy>
获取所有抽屉路由实例
getDrawerInstance({required String stackId, Map<String, Widget>? pageMap, DrawerConfig? drawerConfig, RoutePathCallback? routePathCallback, Widget? notFoundPage}) → RouterProxy
获取抽屉路由实例(多实例)
getInstance({RoutePathCallback? routePathCallback, ExitWindow? exitWindow, Map<String, Widget>? pageMap, Widget? notFoundPage}) → RouterProxy
获取主路由实例(单例)
removeDrawerInstance(String stackId) → void
移除抽屉路由实例 当不再需要某个抽屉路由栈时,调用此方法释放资源