firebase - 下拉菜单不选择数据颤动 Firestore
问题描述
有人可以解释一下为什么我不能在我的下拉列表中选择另一个项目。当我点击时,下拉按钮重置。我没有错误,所以我不知道问题出在哪里。
我遵循了颤振文档,但总是同样的错误。
Widget dropdown(BuildContext context) {
CollectionReference sneakers =
FirebaseFirestore.instance.collection("sneakers");
final _raffle = TextEditingController();
String dropdownValue;
return Column(
children: [
TextFormField(
controller: _raffle,
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
}
return null;
},
decoration: InputDecoration(
labelText: "raffles",
),
),
StreamBuilder<QuerySnapshot>(
stream: sneakers.snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Something went wrong');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Text("Loading");
}
return new DropdownButton<String>(
value: dropdownValue,
icon: const Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
print(newValue);
});
},
items: snapshot.data.docs.map((DocumentSnapshot doc) {
return new DropdownMenuItem<String>(
value: doc.reference.id.toString(),
child: Text(
doc['name'],
));
}).toList(),
);
},
),
解决方案
推荐阅读
- azure-devops-server-2019 - Azure devops 服务器文件系统触发器
- javascript - iframe 文件上传器提交到新标签
- f# - 使用附加字段扩展记录
- sql - 删除 SQL Server 2008 的 concat 和 IIF 函数
- python - 在 jupyter notebook 中使用 bash_profile 变量
- .net - .NET 不支持请求的安全协议
- python - 我做了一个登录系统,但是当我运行它时,它出现了一个意想不到的结果,你能修复它或改进它吗?
- python - Ansible 奇怪的错误:错误是:'str object' 没有属性'ip'
- java - 使用 MockServer 测试 HttpRequest 的主体时如何忽略命名空间
- java - 在 apache ctakes 中添加自定义编写器