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

iOS系统中,点击status bar无法自动回到顶部 #138

Closed
arieslee opened this issue Nov 23, 2018 · 4 comments
Closed

iOS系统中,点击status bar无法自动回到顶部 #138

arieslee opened this issue Nov 23, 2018 · 4 comments

Comments

@arieslee
Copy link

比如,我们,有上拉加载更多的功能,我加载几次以后,想点击手机上的最顶部的status bar回到顶部,无法实现!!!
貌似在flutter的程序中,有 上拉加载的功能或者说自定义了scrollController的,并传回到ListView或者GridView中,这些都无法地中滚动到顶部!

[✓] Flutter (Channel dev, v0.11.9, on Mac OS X 10.13.6 17G65, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.29.1)
[✓] Connected device (1 available)
@CarGuo
Copy link
Owner

CarGuo commented Nov 23, 2018

因为 Scaffold 限制的。
看它的源码可知,内部已经有了这个判断,而 _primaryScrollController 是私有的,并且没有对外开放接口和重载,而在 Scaffold中使用 ListView等之类的, 其 _primaryScrollController.hasClients 会一直等于false。

    if (themeData.platform == TargetPlatform.iOS) {
      _addIfNonNull(
        children,
        GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: _handleStatusBarTap,
          // iOS accessibility automatically adds scroll-to-top to the clock in the status bar
          excludeFromSemantics: true,
        ),
        _ScaffoldSlot.statusBar,
        removeLeftPadding: false,
        removeTopPadding: true,
        removeRightPadding: false,
        removeBottomPadding: true,
      );
    }

目前两个方案

1、等待官方新版本优化处理
2、自己自定义一个 Scaffold

@arieslee
Copy link
Author

因为 Scaffold 限制的。
看它的源码可知,内部已经有了这个判断,而 _primaryScrollController 是私有的,并且没有对外开放接口和重载,而在 Scaffold中使用 ListView等之类的, 其 _primaryScrollController.hasClients 会一直等于false。

    if (themeData.platform == TargetPlatform.iOS) {
      _addIfNonNull(
        children,
        GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: _handleStatusBarTap,
          // iOS accessibility automatically adds scroll-to-top to the clock in the status bar
          excludeFromSemantics: true,
        ),
        _ScaffoldSlot.statusBar,
        removeLeftPadding: false,
        removeTopPadding: true,
        removeRightPadding: false,
        removeBottomPadding: true,
      );
    }

目前两个方案

1、等待官方新版本优化处理
2、自己自定义一个 Scaffold

嗯,我也看到Scaffold的源码了!
我现在想,没有办法在Flutter的程序中监控status bar的tap事件,然后我们自己实现回到顶部的方法!!

@CarGuo
Copy link
Owner

CarGuo commented Nov 23, 2018

可以的,直接参考 Scaffold 源码,自己自定义一个,外放接口就可以临时解决。

@arieslee
Copy link
Author

可以的,直接参考 Scaffold 源码,自己自定义一个,外放接口就可以临时解决。

嗯,目前看来,只能自己实现Scaffold了

@CarGuo CarGuo closed this as completed Nov 23, 2018
@CarGuo CarGuo mentioned this issue Nov 21, 2019
@byue666 byue666 mentioned this issue Dec 19, 2019
@w497763094 w497763094 mentioned this issue Mar 10, 2020
@JevonShi JevonShi mentioned this issue Mar 10, 2020
@HaobinXu HaobinXu mentioned this issue Mar 20, 2020
@luan823230 luan823230 mentioned this issue Mar 24, 2020
@MrHGJ MrHGJ mentioned this issue May 19, 2020
@hzg1105 hzg1105 mentioned this issue Jun 14, 2020
@wangkr wangkr mentioned this issue Jul 4, 2020
@gss3000 gss3000 mentioned this issue Jul 8, 2020
@Liway Liway mentioned this issue Jun 22, 2022
@jayVRIY jayVRIY mentioned this issue Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants