Home > Blockchain >  How do I put simple FireBase data into a ListView?
How do I put simple FireBase data into a ListView?

Time:10-04

How do I get some FireBase data into a ListView?

The following code successfully returns a list of products from FireBase:

final CollectionReference _products = FirebaseFirestore.instance.collection('products');
Future<List> getList() async {
  QuerySnapshot querySnapshot = await _products.get();
  final temp = querySnapshot.docs.map((doc) => doc.data()).toList();
  return temp;
}

The returned data looks like this:

[{quantity: 1.0, name: Greek Yogurt            
  • Related