Reputation: 71
i am trying to load this data from firebase:
Widget BlogList() {
return Container(
child: Column(
children: [
blogSnapshot != null ? ListView.builder(
itemCount: blogSnapshot.docs.length,
shrinkWrap: true,
itemBuilder: (context, index){
return BlogTile(
authorName: blogSnapshot.docs[index].data['authorName'],
title: blogSnapshot.docs[index].data['title'],
description: blogSnapshot.docs[index].data['description'],
imgUrl: blogSnapshot.docs[index].data['imgUrl'],
);
},
): Container(
alignment: Alignment.center,
child: CircularProgressIndicator(),)
],
),
);
}
but i am getting this error:
Error: The operator '[]' isn't defined for the class 'Map<String, dynamic> Function()'.
- 'Map' is from 'dart:core'.
Try correcting the operator to an existing operator, or defining a '[]' operator.
authorName: blogSnapshot.docs[index].data['authorName'],
^
pls have me out here with this error
Upvotes: 0
Views: 514
Reputation: 11
Do this:
itemBuilder: (context, index){
return BlogTile(
authorName: blogSnapshot.docs[index].data()['authorName'],
title: blogSnapshot.docs[index].data()['title'],
description: blogSnapshot.docs[index].data()['description'],
imgUrl: blogSnapshot.docs[index].data()['imgUrl'],
);
Upvotes: 1
Reputation: 44186
I'm guessing that somewhere in that chain (like data) is a function, and needs invoking by adding (). Use your IDE to verify the type of data.
Upvotes: 0