Skip to content

Instantly share code, notes, and snippets.

@Ivy-Walobwa
Created September 5, 2020 17:18
Show Gist options
  • Save Ivy-Walobwa/be55f5a6bee288f5e4932bbcd395d150 to your computer and use it in GitHub Desktop.
Save Ivy-Walobwa/be55f5a6bee288f5e4932bbcd395d150 to your computer and use it in GitHub Desktop.
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