Flutter 如何获取可迭代 .toList() 列表的长度?
Flutter How to get length of a iterable .toList() list?
我想用来自 FirebaseFirestore 的卡片显示一个 ListView。另外,我想显示总共有多少张卡片:
int Length = 0; //?
如何获取可迭代 .toList() 列表的长度?
Column(
children: snapshot.data!.docs
.map(
(doc) =>
Card(
title: doc["title"],)
.toList(
growable: true,
),
),
),
Column(
...snapshot.data!.docs
.asMap().map((index, value) => MapEntry(index, Card(
title: value["title"],)))
.values.toList(
growable: true,
),
),
我想用来自 FirebaseFirestore 的卡片显示一个 ListView。另外,我想显示总共有多少张卡片:
int Length = 0; //?
如何获取可迭代 .toList() 列表的长度?
Column(
children: snapshot.data!.docs
.map(
(doc) =>
Card(
title: doc["title"],)
.toList(
growable: true,
),
),
),
Column(
...snapshot.data!.docs
.asMap().map((index, value) => MapEntry(index, Card(
title: value["title"],)))
.values.toList(
growable: true,
),
),