I have an app I need to get those data from firestore database to the Listview on flutter one by one. I tried many things like a stream builder and future builder but I could not get because my database works with nested data if you have any suggestions please let me know thanks a lot. is there any solution to reading all this nested data? sometimes item name can be different so can I read if nested data have id or quantity value
I already used this but it does not work:
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class cart_page extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection("cart").where("quantity",
isGreaterThanOrEqualTo: 1).snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot>
snapshot) {
if (!snapshot.hasData) return new Text("There is no expense");
return new ListView(children: getExpenseItems(snapshot));
});
}
getExpenseItems(AsyncSnapshot<QuerySnapshot> snapshot) {
return snapshot.data.documents
.map((doc) => new ListTile(
title: new Text(doc["itemName"]),
subtitle: new Text(doc["quantity"]))
)
.toList();
}
}
