Hope you’re safe and doing great. Okay so my problem is that I want to use the index of the cardBuilder
cardBuilder: (context, index) => Card(
In the swipeUpdateCallback, I wanna use it when I swipe to the right or to the left, How can I do that? How do I call the index in swipeUpdateCallback?
swipeUpdateCallback:
(DragUpdateDetails details, Alignment align) {
if (align.x < 0) {
_dataService.seenPost(
welcomeImages[_index].id, ///want to use the index here///
welcomeImages[_index].seen, ///want to use the index here///
welcomeImages[_index].imgPath); ///want to use the index here///
}
Here’s the full code of the widget:
child: new TinderSwapCard(
swipeUp: true,
swipeDown: true,
orientation: AmassOrientation.BOTTOM,
totalNum: welcomeImages.length,
stackNum: 3,
swipeEdge: 4.0,
maxWidth: MediaQuery.of(context).size.width * 1.5,
maxHeight: MediaQuery.of(context).size.width * 1.5,
minWidth: MediaQuery.of(context).size.width * 1.4,
minHeight: MediaQuery.of(context).size.width * 1.4,
cardBuilder: (context, index) => Card( ///Here's the index i want to use///
child: SingleChildScrollView(
child: Column(
children: [
Text('s'),
new Image.network(
'${welcomeImages[index].imgPath}',
fit: BoxFit.cover,
),
],
),
),
),
cardController: controller = CardController(),
swipeUpdateCallback:
(DragUpdateDetails details, Alignment align) {
if (align.x < 0) {
_dataService.seenPost(
welcomeImages[index].id, ///want to use the index here///
welcomeImages[index].seen,
welcomeImages[index].imgPath);
} else if (align.x > 0) {
//Card is RIGHT swiping
}
},