栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何将Firestore文档列表绑定到Flutter中的下拉菜单?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何将Firestore文档列表绑定到Flutter中的下拉菜单?

new StreamBuilder<QuerySnapshot>(    stream: Firestore.instance.collection('categories').snapshots(),    builder: (context, snapshot){      if (!snapshot.hasData) return const Center(        child: const CupertinoActivityIndicator(),      );      var length = snapshot.data.documents.length;      documentSnapshot ds = snapshot.data.documents[length - 1];      _queryCat = snapshot.data.documents;      return new Container(        padding: EdgeInsets.only(bottom: 16.0),        width: screenSize.width*0.9,        child: new Row(          children: <Widget>[ new Expanded(     flex: 2,     child: new Container(       padding: EdgeInsets.fromLTRB(12.0,10.0,10.0,10.0),       child: new Text("Category",style: textStyleBlueBold,),     ) ), new Expanded(   flex: 4,   child:new InputDecorator(     decoration: const InputDecoration(       //labelText: 'Activity',       hintText: 'Choose an category',       hintStyle: TextStyle(         color: primaryColor,         fontSize: 16.0,         fontFamily: "OpenSans",         fontWeight: FontWeight.normal,       ),     ),     isEmpty: _category == null,     child: new DropdownButton(       value: _category,       isDense: true,       onChanged: (String newValue) {         setState(() {_category = newValue;dropDown = false;print(_category);         });       },       items: snapshot.data.documents.map((documentSnapshot document) {         return new DropdownMenuItem<String>(  value: document.data['title'],  child: new Container(    decoration: new BoxDecoration(        color: primaryColor,        borderRadius: new BorderRadius.circular(5.0)    ),    height: 100.0,    padding: EdgeInsets.fromLTRB(10.0, 2.0, 10.0, 0.0),    //color: primaryColor,    child: new Text(document.data['title'],style: textStyle),  )         );       }).toList(),     ),   ), ),          ],        ),      );    });


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/404246.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号