例如,我使用Firestore来存储项目的数量。
假设我在Firestore中有。如何创建从图1到图8的下拉列表。
例如,如果,列表将返回从1到10的图?
在Firestore我有
图8
在Flutter中,我想要一个基于给定数字的下拉列表。
图1图2图3图4图5图6图7图8
发布于 2020-07-08 17:22:20
您可以使用Iterable上的forEach循环来完成此操作:
List<int> plots = [];
int val = 0;
// In the build method
DropdownButton<int>(
value: value,
items: [
for(var plot in plots)
DropdownMenuItem<int>(child: Text("$plot"))
],
onChanged: (val) => setState(() => value = val)),
),https://stackoverflow.com/questions/62791121
复制相似问题