Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Future getCategories() async {
- var firestore = Firestore.instance;
- QuerySnapshot qn = await firestore.collection("categories").getDocuments();
- return qn.documents;
- }
- @override
- Widget build(BuildContext context) {
- return Container(
- child:FutureBuilder(
- future:getCategories(),
- builder:(context, snapshot){
- if(snapshot.connectionState == ConnectionState.waiting){
- return Center(
- child:Text("Loading...")
- );
- }
- else
- {
- return GridView.builder(
- itemCount: snapshot.data.length,
- gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisSpacing: 6.0, mainAxisSpacing: 6.0, crossAxisCount: 2),
- itemBuilder: (BuildContext context, int index) {
- return SingleCategory(
- category_name: snapshot.data[index].data["title"],
- category_picture: snapshot.data[index].data["picture"],
- );
- }
- );
- }
- }
- )
- );
Add Comment
Please, Sign In to add comment