class _FooState extends State<Foo> {
TextEditingController _controller;
@override
void initState() {
super.initState();
_controller = new TextEditingController(text: '初始值');
}
@override
Widget build(BuildContext context) {
return new Column(
children: <Widget>[
new TextField(
//设置controller,
controller: _controller,
),
new RaisedButton(
onPressed: () {
//清除输入
_controller.clear();
},
child: new Text('清除'),
),
],
);
}
}