【发布时间】:2020-08-22 17:19:59
【问题描述】:
我使用这段代码来加载一个新页面,但它什么也没做! 它与StatefulWidget有关吗? (MaterialButton 在一个 stful 小部件下)
MaterialButton(
onPressed: () {
titlenote = titleinput.text;
subtitlenote = subtitleinput.text;
Navigator.of(context).pop();
new MaterialPageRoute(builder: (context) {
return notes();
});
},
这是 newpage stless 小部件:
class notes extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: new Column(children: <Widget>[
new Container(
padding: EdgeInsets.fromLTRB(8, 20, 8, 20),
color: Colors.transparent,
child: new CheckboxListTile(
value: true,
onChanged: (bool a) {},
title: Text("$titlenote"),
selected: true,
checkColor: Colors.green,
activeColor: Colors.black,
tristate: true,
subtitle: Text("$subtitlenote"),
),
alignment: Alignment.center,
)
]),
);
}
}
【问题讨论】: