Skip to content

DraggableScrollableSheet which is called by showModalBottomSheet and contains Slivers doesn't work correctly #116427

Closed

Description

@gidrokolbaska

Steps to Reproduce

  1. Paste the code from the sample below under MaterialApp's home property
  2. Run the app and press the bugs button
  3. A draggable scrollable sheet will appear.

Actual results:

  1. If you begin dragging the sheet fast enough and immediately release the finger, it will snap to the top and won't scroll the ListView further (but it definitely should though). However, it works fine if you keep holding the finger. Same thing applies when you scroll in opposite direction.
2022-12-02.19.38.56.mov
  1. showModalBottomSheet's useSafeArea property should have only top set to true but in our case it pads from both sides for some reason...
    image

  2. Sometimes, when you want to dismiss the bottom scrollable sheet by dragging, it will stick to the bottom instead of disappearing, even though there are only 2 snap sizes specified (0.8 and 1.0):

2022-12-02.19.41.44.mov
  1. If you open the sheet, it can't be dismissed by dragging it down until you drag it up first (when both minChildSize and snapSizes are provided:
2022-12-02.19.45.04.mov
  1. Why dismiss threshold is missing in this widget? It should be present.

Expected results:

  1. Proper scrolling behavior which should be synced. Here is the example:
RPReplay_Final1669999675.2.mov
  1. There should be an exposed option to disable bottom padding when using useSafeArea.
  2. (and also 5) How can I achieve proper dismiss behavior? Also, the dismiss threshold should be implemented, e.g. if you didn't scroll the sheet down enough, it should snap back to the initial snap point using proper physics simulation.
  3. Is it intended that I can't dismiss the bottomsheet when both properties are applied?
Code sample
import 'package:flutter/material.dart';

class TestScreen extends StatelessWidget {
  const TestScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            showModalBottomSheet(
              enableDrag: true,
              useSafeArea: true,
              clipBehavior: Clip.hardEdge,
              shape: const RoundedRectangleBorder(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(20),
                  topRight: Radius.circular(20),
                ),
              ),
              context: context,
              isScrollControlled: true,
              builder: (context) {
                return DraggableScrollableSheet(
                  expand: false,
                  initialChildSize: 0.8,
                  snap: true,
                  snapSizes: const [0.8, 1.0],
                  builder: (context, scrollController) {
                    return CustomScrollView(
                      controller: scrollController,
                      physics: const ClampingScrollPhysics(),
                      slivers: [
                        SliverPersistentHeader(
                          delegate: TestSliverAppBar(),
                          pinned: true,
                        ),
                        SliverList(
                          delegate: SliverChildBuilderDelegate(
                            (_, index) => ListTile(
                              title: Text("Index: $index"),
                            ),
                            childCount: 50,
                          ),
                        )
                      ],
                    );
                  },
                );
              },
            );
          },
          child: const Text(
            'bugs',
          ),
        ),
      ),
    );
  }
}

class TestSliverAppBar extends SliverPersistentHeaderDelegate {
  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return Container(
      color: Colors.pink,
    );
  }

  @override
  double get maxExtent => 100;

  @override
  double get minExtent => 50;

  @override
  bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
      true;
}
Logs
[!] Flutter (Channel master, 3.6.0-14.0.pre.2, on macOS 12.6 21G115 darwin-arm64, locale ru-RU)
    • Flutter version 3.6.0-14.0.pre.2 on channel master at /Users/gidrokolbaska/Developer/flutter
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.16.0/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/gidrokolbaska/Developer/flutter. Consider adding
      /Users/gidrokolbaska/Developer/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7572ce907f (35 hours ago), 2022-12-01 01:07:29 -0500
    • Engine revision 51356bf895
    • Dart version 2.19.0 (build 2.19.0-444.0.dev)
    • DevTools version 2.20.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to
      perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/gidrokolbaska/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (3 available)
    • iPhone 12 (mobile) • 070B14C3-C297-4A54-A136-A502B61105DF • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 108.0.5359.71

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

Activity

  1. darshankawar commented on Dec 5, 2022

    @darshankawar
    Member

    Thanks for the report @gidrokolbaska
    I tried your code sample and observed mixed response. The scroll you mentioned in point 1 seem to be working fine, but was able to see point 3 sometimes, ie, it getting stuck at the bottom.

    116427.mov

    Can you also confirm the same behavior on latest master / stable ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 5, 2022
  3. gidrokolbaska commented on Dec 7, 2022

    @gidrokolbaska
    Author

    @darshankawar Hi!
    Yes, the behavior is absolutely the same on the latest master. Can't use stable because showModalbottomSheet doesn't have useSafeArea yet on this branch

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 7, 2022
  5. gidrokolbaska commented on Dec 7, 2022

    @gidrokolbaska
    Author

    Your video also indicates issue №1 at 0:19. I see that you had to scroll twice :) To reproduce it, all you have to do is to touch the screen and swipe it up and immediately release the finger. The bottomsheet will expand to top, but the inner listview won't scroll no matter how fast you've swiped, unless you keep holding the finger for a little longer.
    Here is the video (you can see the semi-transparent circle behind the cursor indicating how much do I hold the LMB):

    2022-12-07.15.16.42.mov
  6. darshankawar commented on Dec 8, 2022

    @darshankawar
    Member

    Thanks for the update. Based on my findings, adding applicable lables for team's attention.

    master flutter doctor -v
    
    
    [!] Flutter (Channel master, 3.7.0-4.0.pre.38, on macOS 12.2.1 21D62 darwin-x64,
        locale en-GB)
        • Flutter version 3.7.0-4.0.pre.38 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 521028c808 (8 hours ago), 2022-12-07 13:46:17 -0800
        • Engine revision 67254d6e4b
        • Dart version 2.19.0 (build 2.19.0-467.0.dev)
        • DevTools version 2.20.0
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  7. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    f: scrollingViewports, list views, slivers, etc.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Dec 8, 2022
  8. darrenaustin commented on Dec 9, 2022

    @darrenaustin
    Contributor

    @Piinks any idea what's going on here?

  9. Piinks commented on Dec 9, 2022

    @Piinks
    Contributor

    This should definitely be split out into individual issues. It is difficult to discuss/diagnose and resolve when one issue has several issues in it.

  10. gidrokolbaska commented on Dec 10, 2022

    @gidrokolbaska
    Author

    @Piinks Hi! So I basically have to create separate issues and mention the current one in them, right?

  11. Piinks commented on Dec 12, 2022

    @Piinks
    Contributor

    Hi! Yes, thank you! We ask that each issues is individual and actionable with a minimal snippet of code that reproduces the given issue. This helps keep issues focused and fixable, it can be hard to keep track of which one of several we are talking about, as you can see from the conversation above already. :)
    You are welcome to ping me on the individual issues. Thanks!
    https://github.com/flutter/flutter/wiki/Issue-hygiene

  12. gidrokolbaska commented on Dec 13, 2022

    @gidrokolbaska
    Author

    Understood. Closing this one then. Will create separate ones soon. Thanks for clarification :)

  13. Piinks commented on Dec 13, 2022

    @Piinks
    Contributor

    Thanks very much! I took a look at each and left some comments. :)

  14. github-actions commented on Mar 5, 2023

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingViewports, list views, slivers, etc.found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions