'cant display collection data from flutter firestore
I am trying to obtain the data of my documents in a ListView from doc. It tends to receive the data I see an error at doc['title'] stating :
The operator
[]isn't defined for the typeObject? Function()
Also when I print it I see this :
Closure: () => Map<String, dynamic> from Function 'data':.
StreamBuilder(
stream: ref.snapshots(),
builder:(context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Something went wrong');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
}
return ListView.builder(itemCount: snapshot.data!.docs.length,
itemBuilder: (context,index) {
var doc = snapshot.data!.docs[index].data;
print(doc);
return ListTile(
title: Text('title'),
);
}
);
}
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
