serenader2014 / flutter_carousel_slider

A flutter carousel widget, support infinite scroll, and custom child widget.
https://pub.dev/packages/carousel_slider
MIT License
1.56k stars 527 forks source link

Interactive viewer not working with carousel slider #378

Open Maverick-Wolf opened 1 year ago

Maverick-Wolf commented 1 year ago

Wrapping the Image.asset with interactive viewer inside the carousel slider doesn't seem to be working, as am unable to zoom in the images

tomasweigenast commented 1 year ago

The same here!

HankG commented 1 year ago

I was able to get this working by setting the disableGesture setting on CarouselSlider to true. It can still be a bit finicky where I have to tap once on the image and then I can zoom in. Panning still doesn't work like it usually does except when there is only one image though.

swkim-lbstech commented 1 year ago

same issue

EArminjon commented 9 months ago

I was able to make photo_view working using the disableGesture property at true interestingly disableGesture still allow slide to be scrollable. I think disableGesture'name is not well relevant.

nWacky commented 2 months ago

Under the hood this library is using PageView.builder

PageView is scrollable.

InteractiveViewer inside PageView doesn't work with scaling very well because both are listening to scroll events.

It seems to be a flutter issue: https://github.com/flutter/flutter/issues/68594

On stackoverflow people are suggesting to:

  1. listen to onInteractionEnd in InteractiveViewer. Get if child is zoomed in using TransformationController
  2. set PageView scroll physics to NeverScrollableScrollPhysics when child is zoomed in
  3. allow scrolling when child is not zoomed in

Perhaps, it's better to disable interaction/scrolling in carousel and only listen to onInteraction* events in InteractiveViewer.

Then when child is not zoomed in, panning can be detected from onInteraction* manually. Then carousel could be switched to next slide using PageController

When child is zoomed in only let InteractiveViewer handle panning and do nothing with PageController.