我写了一些显示表单的代码。提交按钮是IconButton类型。我想通过单击进入应用程序的主页,但这会返回一个错误。
这是扑扑的形式
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
IconButton(
iconSize: 80.0,
icon: Image.asset("images/send.png"),
onPressed: () {}
我希望通过单击或按下
来链接“提交”按钮答案 0 :(得分:0)
要从一页路由到另一页,您需要在materialapp小部件中添加路由。以下示例:
MaterialApp(
home: Firstpage(),
routes: <String,WidgetBuilder>{
"/SecondPage": (BuildContext context) => new SecondScreen()
}
)
然后在您的代码上简单地输入:
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
IconButton(
iconSize: 80.0,
icon: Image.asset("images/send.png"),
onPressed: () {
Navigator.of(context).pushNamed("/SecondPage")
}
)
)
希望这会有所帮助。