fluttercandies / extended_nested_scroll_view

extended nested scroll view to fix following issues. 1.pinned sliver header issue 2.inner scrollables in tabview sync issue 3.pull to refresh is not work. 4.do without ScrollController in NestedScrollView's body
MIT License
591 stars 117 forks source link

使用TabBarView/PageView时 滚动所有视图,只有当前视图滚动 #125

Closed MrUncleX closed 1 year ago

MrUncleX commented 1 year ago

比如有tab1 tab2 tab3 。当前视图是tab2.调用以下代码只有tab2滚动。其他的tab1 tab3 位置没有变化。我想要tab1 tab3都滚动到指定位置该如何做。 用的flutter版本是3.7.3,我是参考这个代码使用的。 https://github.com/fluttercandies/extended_nested_scroll_view/blob/master/example/lib/pages/complex/scroll_to_top.dart

        _key.currentState?.innerController.positions.forEach((position) {
          position.jumpTo(0.0);
        });
zmtzawqlp commented 1 year ago

onlyscrollsingle 设置成 false

MrUncleX commented 1 year ago

是指这个值 onlyOneScrollInBody: false 吗? scroll_to_top.dart这文件没设置,里面值默认是false。

zmtzawqlp commented 1 year ago

你是想代码控制吗? 你写的那个也可以。还有个outercontroller 就看你需求是什么

MrUncleX commented 1 year ago

如这个视频只有视图可见时才滚的动,不可见的视图没滚动。 我是想实现控制不可见的视图也滚动到指定位置 https://user-images.githubusercontent.com/15188610/223954157-b073b273-b3f7-4711-aa11-505fbb640b7f.mp4

zmtzawqlp commented 1 year ago

这个没用?

        _key.currentState?.innerController.positions.forEach((position) {
          position.jumpTo(0.0);
        });
zmtzawqlp commented 1 year ago

你要为每个列表 使用 AutomaticKeepAliveClientMixin 保持状态,不然切换的时候,position 已经从controller 里面 dettach了。。所以无效

MrUncleX commented 1 year ago

使用了AutomaticKeepAliveClientMixin 结果还是不可见的视图没滚动。遍历的日志也有输出position。 图片

MrUncleX commented 1 year ago

使用了AutomaticKeepAliveClientMixin 结果还是不可见的视图没滚动。遍历的日志也有输出position。 图片

而且切回去没滚动页面再点击滚动。输出position的地址没有变化,说明position没有销毁重建,keepAlive应该是生效了。 图片

zmtzawqlp commented 1 year ago

jump 和 animateTo 都被重载了。你只能设置 onlyOneScrollInBody 为 false ,才会都走。你发的demo onlyOneScrollInBody 是 true