Photo_view: PhotoViewGallery with non PhotoView widget child

Created on 19 Apr 2019  路  6Comments  路  Source: fireslime/photo_view

Is your feature request related to a problem? Please describe.
I'm building some kind of app internal gallery, and it has videos
I've tried to just include PhotoView widget in PageController, but with this approach PhotoView doesn't work at all

Describe the solution you'd like
I want PhotoViewGallery.builder to be able to accept non PhotoView widget

Best api, IMHO, would be like following:

    PhotoViewGallery.builder(
      pageController: PageController(initialPage: initialIndex),
      itemCount: assets.length,
      builder: (_, i) =>
        PhotoViewGalleryPageOptions(
          imageProvider: assets[i].isVideo ? null : assets[i].image,
          notImage: assets[i].isVideo ? assets[i].videoWidget : null,
        ),
    ),
Gallery enhancement

Most helpful comment

@rostopira added custom child support on #131

      PhotoViewGalleryPageOptions.customChild(
            child: Container(
              width: 300,
              height: 300,
              child: SvgPicture.asset(
                item.resource,
                height: 200.0,
              ),
            ),
            childSize: const Size(300, 300),
            initialScale: PhotoViewComputedScale.contained,
            minScale: PhotoViewComputedScale.contained * (0.5 + index / 10),
            maxScale: PhotoViewComputedScale.covered * 1.1,
            heroTag: item.id,
      )

All 6 comments

I've found PhotoView.customChild but I want video widget appear as is, taking whole available space and no scaling

Perhaps a new constructor such as PhotoViewGalleryPageOptions.customChild would help you.

Yeah, I will try to implement it
UPD: well, no luck, feel like an idiot now :D

@rostopira added custom child support on #131

      PhotoViewGalleryPageOptions.customChild(
            child: Container(
              width: 300,
              height: 300,
              child: SvgPicture.asset(
                item.resource,
                height: 200.0,
              ),
            ),
            childSize: const Size(300, 300),
            initialScale: PhotoViewComputedScale.contained,
            minScale: PhotoViewComputedScale.contained * (0.5 + index / 10),
            maxScale: PhotoViewComputedScale.covered * 1.1,
            heroTag: item.id,
      )

Thank you for this change and awesome plugin!

I will release it as 0.3.1
Update: done

Was this page helpful?
0 / 5 - 0 ratings

Related issues

criswonder picture criswonder  路  5Comments

clragon picture clragon  路  8Comments

Creolophus picture Creolophus  路  4Comments

Purus picture Purus  路  3Comments

RustFisher picture RustFisher  路  6Comments