i am trying to get data from Firebase Firestore and getting the following error, the same code was working a month ago with my other app, it would be great if you could help
Class 'List' has no instance getter 'lenght'. Receiver: Instance(length:2) of '_GrowableList' Tried calling: lenght
return Scaffold(
body: StreamBuilder(
stream: FirebaseFirestore.instance
.collection('Sell')
.orderBy('TS', descending: true)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.data == null)
return Center(
child: CircularProgressIndicator(
backgroundColor: Colors.red,
valueColor:
new AlwaysStoppedAnimation<Color>(Colors.cyan[400]),
),
);
return ListView.builder(
itemCount: snapshot.data.documents.lenght,
itemBuilder: (context, index) => SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 120,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(7),
boxShadow: [
BoxShadow(
color: Colors.grey[400],
spreadRadius: 2,
blurRadius: 3)
]),
child: Row(
children: [
Container(
width: 120,
height: 120,
child:ClipRRect(
child: Image.network(
snapshot.data.documents[index]
.get('image 1 Url'),
fit: BoxFit.cover,
),
)),
SizedBox(width: 20),
Column(
children: [
Text(
snapshot.data.documents[index].get('name'),
style: TextStyle(
color: Colors.red,
fontSize: 20,
fontFamily: 'font',
),
),
],
)
],
),
),
),
),
);
},
));
}
}
Change lenght
to length
That's a typo i think. If you wondering why length
. That's because you are trying to get the length of snapshot.data.documents
and initialise it to itemCount
to allow the list to loop your item. I hope this solution works for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.