Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- StreamBuilder<QuerySnapshot>(
- stream: Firestore.instance.collection('route').snapshots(),
- builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
- if (snapshot.hasError) return new Text('Error: ${snapshot.error}');
- switch (snapshot.connectionState) {
- case ConnectionState.waiting:
- return new Text('Loading...');
- default:
- return Container(
- padding: EdgeInsets.symmetric(horizontal: 5.0),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(15.0),
- border: Border.all(
- color: Colors.grey[500],
- style: BorderStyle.solid,
- width: 0.80),
- ),
- child: DropdownButtonHideUnderline(
- child: DropdownButton(
- isExpanded: false,
- elevation: 0,
- hint: Container(
- child: Row(
- children: <Widget>[
- Icon(
- Icons.swap_vert,
- color: Colors.grey[500],
- ),
- Text('Select a Route'),
- ],
- )),
- value: _selectedRoute,
- onChanged: (newValue) {
- setState(() {
- _selectedRoute = newValue;
- });
- },
- items: snapshot.data.documents
- .map((DocumentSnapshot document) {
- return DropdownMenuItem<String>(
- value: document.data['name'],
- child: Row(
- children: <Widget>[
- new Icon(
- Icons.swap_vert,
- size: ScreenUtil.instance.setSp(22.0),
- ),
- new Text(' '),
- new Text(document.data['name']),
- ],
- ),
- );
- }).toList(),
- ),
- ),
- );
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement