serenader2014 / flutter_carousel_slider

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

CarouselSlider & PhotoView, touch conflicts #216

Open Naografix opened 3 years ago

Naografix commented 3 years ago

Hey!

I'm currently using PhotoView to zoom on my Video & Photo carousel and as I can see, I got touch conflict when I want to zoom on my image. In fact, when I'm trying to zoom and swipe to right (to see the right side of my image), my carousel swipe too and my image changes.

Do you know any way to fix this?

return Scaffold(
  resizeToAvoidBottomInset: false,
  body: CarouselSlider.builder(
      itemCount: widget.medias.length,
      options: CarouselOptions(
        aspectRatio: MediaQuery.of(context).size.aspectRatio,
        disableCenter: true,
        initialPage: widget.index,
        enableInfiniteScroll: false,
        viewportFraction: 1.0,
        enlargeCenterPage: false,
      ),
      itemBuilder: (context, index) {
        var media = widget.medias[index];
        if (media.mediaType == MediaType.image) {
          return Hero(
            tag: widget.medias[widget.index].hashCode,
            child: PhotoView(
              minScale: PhotoViewComputedScale.contained,
              imageProvider: CachedNetworkImageProvider(media.url),
              backgroundDecoration: BoxDecoration(color: CustomColor.mainColor),
            ),
          );
        } else {
          return Center(
            child:
                kReleaseMode ? YoutubePlayer(controller: _youtubePlayerControllers[index]) : Container(alignment: Alignment.center, child: Text(media.url)),
          );
        }
      },
  ),
);

ref to PhotoView ticket: https://github.com/fireslime/photo_view/issues/351

davidmartos96 commented 3 years ago

I wanted to replace my dependency to a very similar package but not maintained one (https://github.com/best-flutter/flutter_swiper) but I encountered with this same issue. Although on my case I actually have the PhotoView around the carousel, so that the zoom is not clipped by the near items. PhotoView works correctly with flutter_swiper.

tnitsiri commented 9 months ago

padEnds: false

hadi7khan commented 8 months ago

Any solutions to it?