传参
RaisedButton(
child: Text("跳转到搜索页面"),
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return FormPage(title:"表单"); //传值
}
)
);
},
color: Theme.of(context).accentColor,
textTheme: ButtonTextTheme.primary
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 接收
class FormPage extends StatelessWidget {
final String title;
FormPage({this.title="表单"});
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
child: Text('返回'),
onPressed: (http://www.amjmh.com/v/){
Navigator.of(context).pop(); // 返回上一层
},
),
appBar: AppBar(
title: Text(this.title),
),
body:...
);
}
}
————————————————