【发布时间】:2021-06-11 11:04:15
【问题描述】:
我想在列表视图中使用动态总项目数创建多输入。我使用文本控制器列表,但是当我输入数据时,所有控制器都显示相同的值。
这是我的控制器:
int totalItem = 15;
List<TextEditingController> _color = List.filled(15, TextEditingController());
List<TextEditingController> _brand = List.filled(15, TextEditingController());
在文本字段中实现:
Padding(
padding: const EdgeInsets.only(bottom: 10, left: 20, right: 20),
child: TextFormField(
controller: _color[index],
decoration: InputDecoration(
hintText: "Color",
labelText: "Color",
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 10, left: 20, right: 20),
child: TextFormField(
controller: _brand[index],
decoration: InputDecoration(
hintText: "Brand",
labelText: "Brand",
),
),
),
当运行应用程序文本控制器时显示相同的值。 请帮我解决这个问题?
完整代码:https://github.com/gunartha/listview_with_multi_input
谢谢。
【问题讨论】: