【发布时间】:2020-10-01 22:57:23
【问题描述】:
我的 Web 应用程序要求我从 Firestore 中读取数据,并将这些字段作为值显示到下拉按钮中,并针对每个值设置一个复选框。此下拉菜单将在 Formbuilder 中使用。这是为了确保可以从下拉列表中选择多个值。它看起来像这样。我可以得到一些帮助吗?
Widget _buildFormBuilderForm() {
return Column(
children: <Widget>[
FormBuilder(
key: _fbKey,
child: Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: new StreamBuilder<QuerySnapshot>(
stream:
Firestore.instance.collection("collection")
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return new Text("Please wait");
return new FormBuilderDropdown(
initialValue: dropdownvalue,
hint: new Text("Select
dropdownvalue"),
attribute: 'dropdownvalue',
decoration:
InputDecoration(labelText:"dropdown"),
items:
snapshot.data.documents.map((DocumentSnapshot
document) {
for(int i = 0; i <document.data.length; i++){
print(document.data['Name']);
return new DropdownMenuItem(
value: document.data['Name'],
child: new
Text(document.data['Name'].toString()),
);
}
}).toList(),
onChanged: (value) {
print(value);
setState(() {
dropdownvalue = value;
});
},
);
}),
),
),
],
),
]
),
)))
],
);
}
【问题讨论】:
-
您在创建 ui 或连接到 firebase 时需要帮助吗?你都尝试了些什么。您能否分享一些代码以便我们为您提供帮助。
-
我已经编辑了这个问题。我需要帮助来创建 UI。下拉列表的每个值也应该有对应的复选框。我尝试添加一个复选框,但看起来 FormBuilder 不支持它。
标签: flutter flutter-layout flutter-web