【发布时间】:2022-01-10 12:37:02
【问题描述】:
我的列表视图中有几个数据,我想检查是否有任何数据满足这个 if 条件,让它保持在列表视图顶部的 0 索引处。
ListView.builder(
itemCount: boolS == true ? 7 : data.length,
itemBuilder: (ctx, idx) {
if (boolS == true) {
return shimmer();
}
var index = data[idx];
if (index.userId == userId) {
// make the data stay at the top
}
return Container(
///....
);
),
请问我如何实现这一点。我尝试将其添加到列表视图中
itemCount: boolS == true ? 7 : data.length + 1,
///...
if(idx == 0 && index.userId == userId) {
return Container();
}
但我认为这行不通。所以请你们帮帮我。谢谢
【问题讨论】: