【发布时间】:2021-11-12 09:27:51
【问题描述】:
我想显示一个带有 FirebaseFirestore 卡片的 ListView。另外,我想显示一共有多少张卡片:
int Length = 0; //?
如何获取可迭代 .toList() 列表的长度?
Column(
children: snapshot.data!.docs
.map(
(doc) =>
Card(
title: doc["title"],)
.toList(
growable: true,
),
),
),
【问题讨论】:
-
只需在其末尾添加 .length:.toList().length;
-
错误:参数类型'int'不能分配给参数类型'List
'。 -
在构建widget树之前获取长度,然后在树中使用。
标签: android flutter dart listview