Cubii
Cubii

Reputation: 41

Flutter How to get length of a iterable .toList() list?

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,
             ),
          ),
       ),

Upvotes: 1

Views: 609

Answers (1)

novol
novol

Reputation: 852

Column(
         ...snapshot.data!.docs
             .asMap().map((index, value) => MapEntry(index, Card(
                    title: value["title"],)))
                 .values.toList(
                growable: true,
             ),
          ),
      

Upvotes: 2

Related Questions