Created
September 5, 2020 17:18
-
-
Save Ivy-Walobwa/be55f5a6bee288f5e4932bbcd395d150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Firebase for Flutter Demo', | |
home: Scaffold( | |
body: StreamBuilder( | |
stream: FirebaseFirestore.instance.collection('places').snapshots(), | |
builder: ( BuildContext ctx, AsyncSnapshot<QuerySnapshot> snapshot){ | |
if(snapshot.connectionState == ConnectionState.waiting){ | |
return Center(child: CircularProgressIndicator(),); | |
} | |
final documents = snapshot.data.docs; | |
return ListView.builder( | |
itemBuilder: (ctx, idx) { | |
return Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Text(documents[idx].data()['city']), | |
); | |
}, | |
itemCount: documents.length, | |
); | |
}, | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.add), | |
onPressed: () {}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment