-1

あなたが無事で、うまくやってくれることを願っています。さて、私の問題は、 cardBuilderのインデックスを使用したいということです

cardBuilder: (context, index) => Card(

swipeUpdateCallbackで、右または左にスワイプするときに使用したいのですが、どうすればできますか? 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///
        }

ウィジェットの完全なコードは次のとおりです。

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
        }
      },
4

1 に答える 1