Skip to content

DraggableScrollableSheet with BouncingScrollPhysics, SliverList, and uneven child sizes behaves erratically #169712

@emakar

Description

@emakar

Steps to reproduce

  1. Run following code
  2. Expand sheet and scroll to bottom
  3. Fling down expecting sheet to snap to top
  4. Repeat 2-3 until sheet misbehaves (see video, it either collapses altogether to the minHeight or bounces too much)

Expected results

DraggableScrollableSheet behaves correctly - the same way one achieves applying workarounds (1) or (3) commend in the code below

Actual results

DraggableScrollableSheet behaves incorrectly:

  • either bounces too much (compare to the 2nd video)
  • or collapses altogether, missing 0.5 height snap

Code sample

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const App());

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: Material(child: TestPage()));
  }
}

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

  @override
  Widget build(BuildContext context) {
    final children = List<Widget>.generate(12, (_) {
      return Padding(
        padding: EdgeInsets.only(bottom: 10),
        child: Container(color: Colors.green, height: 100),
      );
    });
    // 1st workaround: removing this line 'fixes' the issue
    children.insert(0, Container(color: Colors.green, height: 100));

    return DraggableScrollableSheet(
      shouldCloseOnMinExtent: false,
      snap: true,
      snapAnimationDuration: const Duration(milliseconds: 220),
      snapSizes: [0.5],
      maxChildSize: 1,
      initialChildSize: 0.5,
      minChildSize: 0.2,
      builder: (context, scrollController) {
        return CustomScrollView(
          // 2nd workaround: removing BouncingScrollPhysics 'fixes' the issue
          physics: const BouncingScrollPhysics(),
          controller: scrollController,
          slivers: [
            SliverList(
              delegate: SliverChildBuilderDelegate((context, index) {
                return children[index];
              }, childCount: children.length),
            ),
            // 3rd workaround: replacing SliverList with this 'fixes' the issue
            // SliverToBoxAdapter(
            //   child: Column(children: children),
            // ),
          ],
        );
      },
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
draggable_scrollable_sheet_issue.mp4
draggable_scrollable_sheet_workaround.mp4

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.4.1 24E263 darwin-arm64, locale en) [275ms]
    • Flutter version 3.32.0 on channel stable at /Users/yauhen/fvm/versions/3.32.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (10 days ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1
    • Pub download mirror https://pub.dev

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [994ms]
    • Android SDK at /Users/yauhen/Library/Android/sdk/
    • Platform android-36, build-tools 35.0.0
    • ANDROID_HOME = /Users/yauhen/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [702ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.3) [7ms]
    • 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 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.100.1) [7ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (3 available) [5.9s]
    • Pixel 6 (mobile) • 24201FDF6008SA • android-arm64  • Android 15 (API 35)
    • macOS (desktop)  • macos          • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)     • chrome         • web-javascript • Google Chrome 136.0.7103.114

[✓] Network resources [756ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions