我有一个程序,其中用户应能够按下按钮,然后该程序应能够生成新的文本框。我该怎么办?
答案 0 :(得分:0)
List<Widget>list = new List();
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Container(
padding: EdgeInsets.all(20.0),
child: new ListView.builder(itemBuilder: (context, index){
Widget widget = list.elementAt(index);
return widget;
}, itemCount: list.length,),),
floatingActionButton: new FloatingActionButton(onPressed: (){
list.add(new TextField(decoration: InputDecoration(hintText: 'Hint ${list.length+1}'),));
setState(() {});
}, child: new Icon(Icons.add),),
);
}