3

I have a widget that returns a carouselslider and I want to zoom and pinch the 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?

Gwhyyy
  • 7,554
  • 3
  • 8
  • 35
asal rad
  • 43
  • 1
  • 5

2 Answers2

0

you can use photo view package

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

this article helps you create what you want.

Ardeshir ojan
  • 1,914
  • 1
  • 13
  • 36
  • 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 :) – Dominik Miedziński Nov 30 '21 at 15:12
  • Did you ever find a solution for the zoom problem? – Junn Sorran Jan 06 '23 at 19:26
-1

To the comment above - I ditched the CarouselSlider and opted to use the PhotoViewGallery widget. It works in the same way and is fairly easy to switch over to as it contains mostly identical fields; it also comes included in the photo_view dependency.

If you're still looking for the carousel functionality (where photos loop around), it's not a built-in option but there's a workaround which you can find here.

Will
  • 1
  • 1) if you want to answer on a comment, better do it in a comments 2) it is better not mention it is comment above or below, but attach direct link to this comment, as it can be different sorting of answers – cheparsky Jun 28 '23 at 10:08