卡在堆栈中不可点击

时间:2019-06-13 03:01:50

标签: flutter dart flutter-animation

我正在遵循https://github.com/devefy/Flutter-Story-App-UI来构建一些UI组件,但似乎无法使卡片可点击。

应该使用PageView构建器来操纵currentPage值来更改页面,但是PageView构建器位于堆栈的顶部,并阻止其下的所有GestureDetectors。

我想不出任何解决方案atm,我们将不胜感激。

PageController cardController =
        PageController(initialPage: images.length - 1);

cardController.addListener(() {
      setState(() {
        currentPage = cardController.page;
      });
    });

Stack(
      children: <Widget>[
          StackedCards(currentPage,postList),
          Positioned.fill(
              child: PageView.builder(
                         itemCount: images.length,
                         controller: cardController,
                         reverse: true,
                         itemBuilder: (context, index) {
                         return Container();
                      },
                    ),
                  )
                ],
              )

1 个答案:

答案 0 :(得分:0)

一些可点击的小部件:GestureDetector, InkWell, InkResponse

  GestureDetector(
      onTap: ...,
      child: Stack(
          children: <Widget>[
              StackedCards(currentPage,postList),
              Positioned.fill(
                  child: PageView.builder(
                             itemCount: images.length,
                             controller: cardController,
                             reverse: true,
                             itemBuilder: (context, index) {
                             return Container();
                          },
                        ),
                      )
                    ],
                  ));