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

CupertinoSliverRefreshControll not work on Android #21820

Closed
TENCAR-RUSSIA opened this issue Sep 13, 2018 · 10 comments · Fixed by #30129
Closed

CupertinoSliverRefreshControll not work on Android #21820

TENCAR-RUSSIA opened this issue Sep 13, 2018 · 10 comments · Fixed by #30129
Assignees
Labels
d: api docs Issues with https://api.flutter.dev/ f: cupertino flutter/packages/flutter/cupertino repository f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically

Comments

@TENCAR-RUSSIA
Copy link

TENCAR-RUSSIA commented Sep 13, 2018

Steps to Reproduce

CupertinoSliverRefreshControll not work on Android. On iOS works perfectly

new CustomScrollView(
          slivers: <Widget>[
            new  CupertinoSliverRefreshControl(
              onRefresh: ,
            ),
            new SliverSafeArea(
              top: true, 
              sliver: new SliverPadding(
                sliver: new SliverList(
                  delegate: new SliverChildBuilderDelegate(
                        (context, index) => ,
                    childCount: ....,
                  ),
                ),
              ),
            ),
          ],
        );

screenshot_1536847924 2 2
simulator screen shot - iphone x - 2018-09-13 at 17 12 26 2

[✓] Flutter (Channel master, v0.8.3-pre.24, on Mac OS X 10.13.6 17G2307, locale ru-RU)
    • Flutter version 0.8.3-pre.24 at /users/tencar/development/flutter
    • Framework revision 387948a239 (2 days ago), 2018-09-11 08:51:42 +0200
    • Engine revision e65beb89da
    • Dart version 2.1.0-dev.4.0.flutter-ef72098353

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/tencar/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update, run:
        brew uninstall --ignore-dependencies libimobiledevice
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.2
    • CocoaPods version 1.6.0.beta.1

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 28.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Connected devices (3 available)
    • Android SDK built for x86 • emulator-5554                            • android-x86 • Android 8.0.0 (API 26) (emulator)
    • iPhone (Андрей)           • e09c97faece05a08ba4dad424760438835e7aa4b • ios         • iOS 11.4.1
    • iPhone X                  • 7C386461-A480-4EAA-B478-26142C473ED0     • ios         • iOS 11.4 (simulator)

! Doctor found issues in 1 category.
@zoechi zoechi added platform-android Android applications specifically framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. f: cupertino flutter/packages/flutter/cupertino repository labels Sep 13, 2018
@zoechi zoechi added this to the Goals milestone Sep 13, 2018
@gildaswise
Copy link
Contributor

gildaswise commented Sep 13, 2018

You need to set physics: BouncingScrollPhysics(), on your CustomScrollView for it to work. You should also change the builder of CupertinoSliverRefreshControl to something more Material, like this:

CupertinoRefreshControl(
    builder: Theme.of(context).platform == TargetPlatform.iOS
        ? buildAppleRefreshIndicator
        : buildAndroidRefreshIndicator,
    onRefresh: ...,
)

I did this on my app and here's a gist with both refresh indicator methods.

@TENCAR-RUSSIA
Copy link
Author

thank you! all works now

@TENCAR-RUSSIA
Copy link
Author

TENCAR-RUSSIA commented Sep 17, 2018

@gildaswise Reopen. If SliverList have only one item refresh indicator not work(on iOS and Android too)

@TENCAR-RUSSIA TENCAR-RUSSIA reopened this Sep 17, 2018
@gildaswise
Copy link
Contributor

@AndreyTCR Is the List occupying all available space or is it only with the item's height? There might not be enough space for the RefreshIndicator to appear, or you are pulling from the middle of the screen instead of right in your list

@TENCAR-RUSSIA
Copy link
Author

TENCAR-RUSSIA commented Sep 17, 2018

@gildaswise problem, i think, on SliverList height. If we have 1 item on it then bounce not work correctly, but if we have more items(more i mean Sliverlist bigger then viewport) then all work correctly.

@Dpuntu
Copy link

Dpuntu commented Oct 15, 2018

I changed the builder of CupertinoSliverRefreshControl to something by gist ,but it‘s still not working on Android @gildaswise

----2018/10/22 update----

You may not be able to swipe on an android device when physics is AlwaysScrollableScrollPhysics. But there's a pit here, you can't do pull-down refresh without the sub controller filling the screen if you
change AlwaysScrollableScrollPhysics to BouncingScrollPhysics. The following code can be pulled down in any case.

class RefreshScrollPhysics extends BouncingScrollPhysics {
  const RefreshScrollPhysics({ScrollPhysics parent}) : super(parent: parent);

  @override
  RefreshScrollPhysics applyTo(ScrollPhysics ancestor) {
    return RefreshScrollPhysics(parent: buildParent(ancestor));
  }

  @override
  bool shouldAcceptUserOffset(ScrollMetrics position) {
    return true;
  }
}

@xster xster added the d: api docs Issues with https://api.flutter.dev/ label Oct 23, 2018
@xster xster added this to Easy fix in iOS Framework Oct 23, 2018
@sgon00
Copy link

sgon00 commented Dec 2, 2018

FYI: I just found out the official example flutter_gallery --> Cupertino --> Pull to refresh does not work on my Android today. I am not sure if this is the same issue.

@xster
Copy link
Member

xster commented Mar 25, 2019

I think the fix here is documentation. Since there are no specs for how an Android + Material native scroll overscroll should behave, we should just offer the components but also make it clear how users can compose the Cupertino components together for use on Android.

Specifically:

  1. Wrap the gallery demo's list with the right scroll physics so it works on Android too.
  2. Document the class doc of CupertinoSliverRefreshControl for how to make it work on Android.
  3. Let the code in the gallery demo point to the class doc for how to make it work on Android.

@xster
Copy link
Member

xster commented Apr 3, 2019

Extracted #30466 from this bug.

@xster xster moved this from Easy fix to Done in iOS Framework Feb 27, 2020
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
d: api docs Issues with https://api.flutter.dev/ f: cupertino flutter/packages/flutter/cupertino repository f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically
Projects
No open projects
iOS Framework
  
Done
Development

Successfully merging a pull request may close this issue.

6 participants