Is there a way to disable PageView clipping effect?

怎甘沉沦 提交于 2020-01-05 13:09:13

问题


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 PageScrollPhysics() to a ListView to achieve this effect. Like this:

var _listView = ListView(physics: PageScrollPhysics());

As @Ferdi said, PageView is not designed for this. So just go with ListView or SingleChildScrollView() and apply the PageScrollPhysics(), 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!



来源:https://stackoverflow.com/questions/53943805/is-there-a-way-to-disable-pageview-clipping-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!