Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some padding between photos in gallery #42

Open
dinhha opened this issue Oct 23, 2018 · 10 comments
Open

Add some padding between photos in gallery #42

dinhha opened this issue Oct 23, 2018 · 10 comments
Labels

Comments

@dinhha
Copy link

dinhha commented Oct 23, 2018

Thanks for your wonderful plugin!

Can you guys, add a padding parameter to PhotoViewGallery or some where else?
I need to add some padding between photos in gallery.

@renancaraujo renancaraujo added the enhancement New feature or request label Oct 23, 2018
@renancaraujo
Copy link
Member

PhotoViewGallery relies on PageView to provide this kind o behavior. The answer is simple: if we can do that with PageView, we can do that with PhotoViewGallery.

@Stmol
Copy link

Stmol commented Feb 16, 2020

I wonder why people are not interested in this basic use case 🧐

So here's my solution (probably not perfect):

return Container(
  child: PhotoViewGallery.builder(
    itemCount: photos.length,
    scrollPhysics: const BouncingScrollPhysics(),
    customSize: MediaQuery.of(context).size, // 1. Set custom child size to fit to screen size
    pageController: PageController(viewportFraction: 1.1), // 2. Set fraction of page viewport more than 100%
    backgroundDecoration: BoxDecoration(
      color: Color(0xFFFFFFFF),
    ),
    builder: (_, index) {
      return PhotoViewGalleryPageOptions.customChild(
        child: Container(
          color: Color(0xFFFFFFFF),
          child: Image(
            image: NetworkImage(photos[index].url1024),
            filterQuality: FilterQuality.medium,
          ),
        ),
        initialScale: PhotoViewComputedScale.contained,
        minScale: PhotoViewComputedScale.contained,
      );
    },
  ),
);

@allanwolski
Copy link

@renancaraujo

Can you review that?
#416

@renancaraujo
Copy link
Member

renancaraujo commented May 8, 2021

@allanwolski thanks for the effort but that won't be merged.

The idea of adding padding to pages is not that simple. Wrapping internal widgets with a padding prevents the image to reach the borders of the viewport, not simply add spacing between pages, as intended.

For more info: flutter/flutter#38739

@renancaraujo
Copy link
Member

renancaraujo commented May 8, 2021

For anyone who come to this issue for now on:

Since the gallery is based on the frameworks page view, we shall not divert too much from it.

We have a workaround above and some on this issue: flutter/flutter#38739

Issue to track this on the framework: flutter/flutter#78200

Consider upvoting that issue to be prioritized by the flutter team.

@allanwolski
Copy link

Thanks for the feedback @renancaraujo

The native_pdf_view package uses photo_view internally and I need to add a padding to the page.

The solution proposed in #416 solves this problem.
Could you see that please?

@renancaraujo
Copy link
Member

The gallery page options have too many options already, a large API is hard to maintain. Simply wrapping with padding and adding yet another parameter makes sense since we have the custom child support.

The better solution for you seems to native_pdf_view allow custom wrapping in the custom child or passing through the padding there.

@guilhermedaldim
Copy link

I have the same issue, I also need to add a padding between the pages.

@renancaraujo
Copy link
Member

Well, we have plenty of workarounds:

One here:
flutter/flutter#38739 (comment)
Another here:
#42 (comment)

Comments above state why this won't be worked on the photo view gallery for the reasons stated above.

To avoid comments like "me too" I will be locking this issue.

If you are facing this issue, you can give a thumbs up in this issue to have the flutter team prioritizing this.

Any further comments or ideas on this matter feel free to open a new issue or call in the discord chat.

@bluefireteam bluefireteam locked and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants