Last active
December 18, 2020 11:12
-
-
Save thecharlieblake/e6c3c64c4bbebe048955bbc2d3c491d2 to your computer and use it in GitHub Desktop.
For Rachel
This file contains hidden or 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 ProductGrid extends StatelessWidget { | |
ProductGrid(this.userDocs); | |
List<DocumentSnapshot> userDocs; | |
IndividualProduct createProductFromSnapshot(DocumentSnapshot document) { | |
return IndividualProduct( | |
document["product_name"], | |
document["image"][0], | |
document["discounted_price"].toString() | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
List<IndividualProduct> products = userDocs.map(createProductFromSnapshot).toList(); | |
return GridView.count( | |
primary: false, | |
padding: const EdgeInsets.all(20), | |
crossAxisSpacing: 10, | |
mainAxisSpacing: 10, | |
crossAxisCount: 2, | |
children: products, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment