我目前只能在此处设置索引。我尝试了各种设置索引的方法,但是不能更改索引的值。此方法来自软件包:
https://pub.dev/packages/flutter_tindercard
由于我正在构建卡,因此可能需要返回索引以正确地与返回卡的后退按钮同步。但是即使我在构建器中执行减量运算符,构建器的索引也只会不断增加。这是构建器的代码:
Widget _cardBuild() {
return TinderSwapCard(
orientation: AmassOrientation.BOTTOM,
totalNum: articleList.length != null ? articleList.length + backCount : 0,
stackNum: 3,
swipeEdge: 1.0,
animDuration: 50,
maxWidth: MediaQuery.of(context).size.width * 0.9,
maxHeight: 410.1,
minWidth: MediaQuery.of(context).size.width * 0.8,
minHeight: 410,
cardBuilder: (context, index) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Conditional.single(
context: context,
conditionBuilder: (BuildContext context) => pendingBack > 0,
widgetBuilder: (BuildContext context) {
return _generateCards(cardIndex);
},
fallbackBuilder: (BuildContext context) {
return _generateCards(index);
},
),
);
},
cardController: controller = CardController(),
swipeUpdateCallback: (DragUpdateDetails details, Alignment align) {
/// Get swiping card's alignment
if (align.x < 0) {
//Card is LEFT swiping
} else if (align.x > 0) {
//Card is RIGHT swiping
}
},
swipeCompleteCallback: (CardSwipeOrientation orientation, int index) {
if (index == articleList.length) {
setState(() {
isOutOfCards = true;
});
} else {
setState(() {
cardIndex++;
});
}
},
);
}
该应用程序的示例屏幕截图: [