in this reader widget i want to change the scrolling behavior so that if i'm zoomed in on an image and move arround the CarouselSlider dosen't slide to the next image unless i'm at the current image boundary.
I tried to change the scrollPhysics with every one I could find, without sucess.
There a similar questions around here, but none answered this problem.
how zoom in carouselslider in flutter?
flutter InteractiveViewer with CarouselSlider very difficult to pinch zoom
Here's the method handling the carousel:
CarouselSlider buildCarouselSlider() {
final double height = MediaQuery.of(context).size.height;
return CarouselSlider.builder(
itemCount: widget.file.pagesCount,
itemBuilder: (context, index, pageViewIndex) => Center(
child: PhotoView(
imageProvider: CachedNetworkImageProvider(widget.file.pagesUrl[index]),
onTapDown: (context, details, controllerValue) {
// Hide app bar on scroll down
setState(() {_showAppBar = !_showAppBar;});
},
backgroundDecoration: const BoxDecoration(color: Colors.black),
),
),
options: CarouselOptions(
autoPlay: false,
enableInfiniteScroll: false,
viewportFraction: 1.0,
enlargeCenterPage: false,
height: height,
clipBehavior: Clip.hardEdge,
pageSnapping: true,
scrollDirection: _axis,
initialPage: widget.file.currentPage,
scrollPhysics: const PageScrollPhysics(),
)
);
}
I ended up finding this tutorial and using the PhotoViewGallery with the PhotoViewGalleryPageOption did the trick.
It's even better as the page border are better defined and don't just start scrolling to the next one as soon as you're on the border.
https://resocoder.com/2019/05/04/flutter-photo-view-gallery-resize-rotate-image-carousel/
Here's my full code for anyone with the same problem: