RouterProxy class
- Inheritance
-
- Mixed-in types
-
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()
→ CustomParser
-
-
dispose()
→ void
-
Discards any resources used by the object.
inherited
-
getArguments<T>()
→ T?
-
获取当前显示页面的参数
-
getCurrentMaterialPage()
→ MaterialPage
-
获取当前显示页面的MaterialPage对象,可用于获取参数
-
getCurrentPage()
→ Widget
-
获取当前显示的页面Widget
-
getLocation()
→ String?
-
-
goRootPage()
→ 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<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