PageView(
controller: _pageController,
allowImplicitScrolling: true,
children: [
...widget.storeImages
.map((image) => GestureDetector(
onHorizontalDragEnd: (drag) {
debugPrint('Drag.......');
},
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
image: DecorationImage(
fit: BoxFit.fill,
image: CachedNetworkImageProvider(image.assetId),
),
),
),
))
.toList(),
],
),
i have a particular number of images in a container i need to move it from left to right and right to left using swipe gestures.
In that container i have 2 arrows back and forward, which it works perfectly because when i try to click it moves forward and backward
Wrapping the children of the PageView
with GestureDetector
is causing the PageView
to not detect the swiping gesture. If you want to execute some code when the user swipes, wrap your PageView
instead:
GestureDetector(
onHorizontalDragEnd: (drag) {
debugPrint('Drag.......');
},
child: PageView(
// ...
),
)
If you need to know the index of the current page being shown, get it from _pageController.page
.