Is there a way to disable PageView clipping effect

2019-08-20 17:00发布

问题:

Let say I have a PageView sized {100x100} with 4 children, so there will be only 1 child visible at the time, until I scroll to the second child. What I want is to make all 4 children are visible on the screen. Is there a way to achieve this?

回答1:

Answering my own question is kind of funny, but I'm doing it anyway, thought that someone might need this.

Thanks to this post: Non-center alignment for PageView with viewportFraction < 1.0

Now I can apply PageScrollPhysic() to a ListView to achieve this effect.

As @Ferdi said, PageView is not designed for this. So just go with ListView or SingleChildScrollView() and apply the PageScrollPhysic(), it will do the trick!



回答2:

You're question seems a bit unclear indeed. I assume what you want is to see all our PageView in a single screen.

Well in not why PageView was created for.

Here a brief description of PageView: https://www.youtube.com/watch?v=J1gE9xvph-A

And here's the official doc for PageView

Also if you still want the effect I would suggest you to encapsulate your four PageView (actually change to Container) into a row with a global gestureDetector.

Hope it's help !!



回答3:

There is a way you can achieve this with the PageView. Define a PageController with a view port fraction you need.

Example:

final PageController _controller = PageController(viewportFraction: 0.3333); 
//(0.3333 i.e 1/3 indicates to fit 3 tiles on view port, for 4 use `0.25` i.e `1/4`)

then pass the controller to the PageView

PageView(
  controller: _controller,
  children: [...] // your page widgets
)

Hope this helps!