flutter的路由与导航
文章目录
定义路由
// 在Scaffold中定义路由,如下
routes: <String, WidgetBuilder>{
// less 路由名称 ,StatelessGroupPage() 要跳转的实例page
'less': (BuildContext context) => StatelessGroupPage(),
'full': (BuildContext context) => StateFullGroupPage(),
}
路由跳转
// 根据路由名称跳转 routerName:'less' 'full'
Navigator.pushNamed(context, routerName);
导航跳转
// 导航直接跳转 page实例: StatelessGroupPage() StateFullGroupPage()
Navigator.push(context, MaterialPageRoute(builder:(context)=>page))
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论