我正在遵循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();
},
),
)
],
)
答案 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();
},
),
)
],
));