移动应用中,通过页面展示其所有元素。在flutter中,这些元素称为路由,它们是有Navigator组件管理。导航器管理一组路由Router对象,并提供了管理堆栈方法,例如Navigator.push和Navigator.pop
页面跳转,不传参
跳转页面
Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){
return new SecondPage());
}))
被跳转页面
Navigator.pop(context);
页面跳转,传参
跳转页面
Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){
return new SecondPage("携带参数"));
}))
被跳转页面
Navigator.pop(context);
页面跳转,被跳转页面返回时回传参数
跳转页面
Navigator.push<String>(context, new MaterialPageRoute(builder: (BuildContext context){
return new SecondPage();
})).then( (String result){
//处理代码
});
被跳转页面
Navigator.pop(context,"携带参数");