Skip to content

Instantly share code, notes, and snippets.

@thecharlieblake
Last active December 18, 2020 11:12
Show Gist options
  • Save thecharlieblake/e6c3c64c4bbebe048955bbc2d3c491d2 to your computer and use it in GitHub Desktop.
Save thecharlieblake/e6c3c64c4bbebe048955bbc2d3c491d2 to your computer and use it in GitHub Desktop.
For Rachel
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