//跳转路由
Navigator.of(context) .push( //页面跳转
MaterialPageRoute( //基本跳转
builder: (BuildContext context) {
return const SearchPage(); //跳转页面
}));
在flutter中路由也是用来处理页面跳转、页面数据传递等操作,主要是通过路由(Route)和导航器(Navigator)来配合实现。
Flutter 中给我们提供了两种配置路由跳转的方式 1.基本路由 2.命名路由。
比如我们现在想从HomePage页面跳转到 SearchPage页面
1、需要在HomePage中引入SearchPage.dart
2、在HomePage中通过navigator.of(context).push()跳转。
Navigator.of(context).push() //属于基本路由跳转。
通过push参数需要一个MaterialPageRoute对象。
需求:从 HomePage 页面跳转到 CategoryPage 页面
1、在CategoryPage 页面定义参数 接收传值
2、跳转页面实现传值