Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. StreamBuilder<QuerySnapshot>(
  2. stream: Firestore.instance.collection('route').snapshots(),
  3. builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
  4. if (snapshot.hasError) return new Text('Error: ${snapshot.error}');
  5. switch (snapshot.connectionState) {
  6. case ConnectionState.waiting:
  7. return new Text('Loading...');
  8. default:
  9. return Container(
  10. padding: EdgeInsets.symmetric(horizontal: 5.0),
  11. decoration: BoxDecoration(
  12. borderRadius: BorderRadius.circular(15.0),
  13. border: Border.all(
  14. color: Colors.grey[500],
  15. style: BorderStyle.solid,
  16. width: 0.80),
  17. ),
  18. child: DropdownButtonHideUnderline(
  19. child: DropdownButton(
  20. isExpanded: false,
  21. elevation: 0,
  22. hint: Container(
  23. child: Row(
  24. children: <Widget>[
  25. Icon(
  26. Icons.swap_vert,
  27. color: Colors.grey[500],
  28. ),
  29. Text('Select a Route'),
  30. ],
  31. )),
  32. value: _selectedRoute,
  33. onChanged: (newValue) {
  34. setState(() {
  35. _selectedRoute = newValue;
  36. });
  37. },
  38. items: snapshot.data.documents
  39. .map((DocumentSnapshot document) {
  40. return DropdownMenuItem<String>(
  41. value: document.data['name'],
  42. child: Row(
  43. children: <Widget>[
  44. new Icon(
  45. Icons.swap_vert,
  46. size: ScreenUtil.instance.setSp(22.0),
  47. ),
  48. new Text(' '),
  49. new Text(document.data['name']),
  50. ],
  51. ),
  52. );
  53. }).toList(),
  54. ),
  55. ),
  56. );
  57. }
  58. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement