Using index of an item in a list

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.

              (DragUpdateDetails details, Alignment align) {
            if (align.x < 0) {
                  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:

return Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        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: [
                    fit: BoxFit.cover,
          cardController: controller = CardController(),
              (DragUpdateDetails details, Alignment align) {
            if (align.x < 0) {
                  welcomeImages[index].id, ///want to use the index here///
            } else if (align.x > 0) {
              //Card is RIGHT swiping

PS: Package used: flutter_tindercard

From what I saw in the example and you must already know index is present in swipeCompleteCallback.

This question has more chances of getting resolved if you open an issue in their GitHub Repo. As as it is more about the plugin than flutter itself.

1 Like