how zoom in carouselslider in flutter?

1,000

you can use photo view package

PhotoView(
          imageProvider: AssetImage(photos),
          backgroundDecoration: BoxDecoration(color: Colors.white),
        ),

this article helps you create what you want.

Share:
1,000
Ardeshir ojan
Author by

Ardeshir ojan

Updated on December 01, 2022

Comments

  • Ardeshir ojan
    Ardeshir ojan over 1 year

    i have a widget that return a carouselslider and i want to zoom and pinch image

    this is my code:

    Widget myPicture() {
    List<Widget> items = [];
    
    for (var i in widget.product.imageUrlList) {
      items.add(
        Image.network(i),
      );
    }
    
    return CarouselSlider(
      items: items,
      options: CarouselOptions(
        enlargeCenterPage: false,
      ),
    );
    
      }
    

    i try to write like this:

    Widget myPicture() {
    
    List<Widget> items = [];
    
    for (var i in widget.product.imageUrlList) {
      items.add(
        Image.network(i),
      );
    }
    
    return InteractiveViewer(
      child: CarouselSlider(
        items: items,
        options: CarouselOptions(
          enlargeCenterPage: false,
        ),
      ),
    );
      }
    

    but it doesn't work too

    what should I do?

    • Abhijith
      Abhijith almost 3 years
      have you tried to enclose InteractiveViewer with image widget @asal rad
  • Dominik Miedziński
    Dominik Miedziński over 2 years
    Yes, it's do the job, but there is one problem. PhotoView enables zoom and move the enlarged image on the screen. Unfortunately the CarouselSlider prevents it, because move is treated as change the page of carousel :)