我的 Firestore 文档中有一个数据流,我想用它来填充下拉按钮的下拉列表。我该怎么做呢?
这是我创建流的地方:
Stream<List<Agency>> getAgency() {
return _db.collection('agency').snapshots().map((snapshot) => snapshot.docs
.map((document) => Agency.fromFirestore(document.data()))
.toList());
}
这是到目前为止的 DropdownButton 代码:
DropdownButton(
value: _chosenAgency,
items: List, <<<< ADD LIST HERE
hint: Text('Choose your Agency'),
onChanged: (String value) {
setState(() {
_chosenAgency = value;
});
},
)
我知道这应该不难,但我找不到任何解决这个问题的帖子。谢谢