我正在讨论这个问题。我希望我的堆栈中的所有物品都可以被拒绝。我可以显示我的所有项目,但只有第一项是可以拒绝的。为什么呢?
以下是代码段:
Widget build(BuildContext context) {
return new StreamBuilder <QuerySnapshot>(
stream: Firestore.instance.collection('records').document(uid).collection("pdrecords").snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData) {
print("snapShot call");
final int recordCount = snapshot.data.documents.length;
print("got data. records: $recordCount");
if (recordCount >0) {
return new Stack (
alignment: listSlideAnimation.value,
children:
snapshot.data.documents.map((DocumentSnapshot document) {
count = count + multiplyFactor; print("count: $count");
index ++;
//print("data: ${document.data}");
return Dismissible(
resizeDuration: null,
dismissThresholds: _dismissThresholds(),
//background: new LeaveBehindView(),
key: ObjectKey(document.documentID) ,
onDismissed: (DismissDirection direction) {
direction == DismissDirection.endToStart
? print("favourite")
: print("remove");
// Do stuff
},
child:
new ListPDRecord(
id: document.documentID,
margin: listSlidePosition.value * count, //new EdgeInsets.only(bottom: 80.0) * count, //listSlidePosition.value * 5.5,
width: listTileWidth.value,
date: document["date"],
),
);
}).toList(),
);
} else {
return NoDataListData();
}
} else {
// No data
return new NoDataListData();
}
});
}
}
我怀疑是KEY,我尝试了不同键的许多变体,例如手动增加索引等,但仍然只允许第一项。
任何指针?
答案 0 :(得分:0)
经过多轮实验,我实现了以下几点,决心解决了这个问题: