Flutter How to get length of a iterable .toList() list?
343
Column(
...snapshot.data!.docs
.asMap().map((index, value) => MapEntry(index, Card(
title: value["title"],)))
.values.toList(
growable: true,
),
),
Author by
Cubii
Updated on January 01, 2023Comments
-
Cubii over 1 year
I want to Display a ListView with Cards from FirebaseFirestore. Also, I want to show how many Cards there are at all:
int Length = 0; //?
How to get length of a iterable .toList() list?
Column( children: snapshot.data!.docs .map( (doc) => Card( title: doc["title"],) .toList( growable: true, ), ), ),
-
Benyamin over 2 yearsjust add .length at the end of it: .toList().length;
-
Cubii over 2 yearsError: The argument type 'int' can't be assigned to the parameter type 'List<Widget>'.
-
Benyamin over 2 yearsGet the length before building the widget tree, and then use it in the tree.
-
-
novol over 2 yearsdid it help you?
-
Cubii over 2 yearscan you tell me how I can set the State of the int Length for the number of the cards?
-
novol over 2 yearswhy do you need it? Your widget will be built based on the length
-
Cubii over 2 yearsthat's the point I want the length based on the generated length of the list? Or does this not work?
-
novol over 2 yearsthis method include itemCount, if you want get length use
snapshot.data!.docs.length