Skip to content

NestedScrollView physics not working #113753

Closed

Description

@EArminjon

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Just scroll the view

Expected results:
Scroll should not work in this example

Actual results:
User can scroll. We lost the ability to have custom physics like Clamping or Bouncing.

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

void main() {
  runApp(const MaterialApp(home: Home()));
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: NestedScrollView(
        physics: const NeverScrollableScrollPhysics(),
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => <Widget>[
          SliverOverlapAbsorber(
            handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
            sliver: const SliverAppBar(
              pinned: true,
              elevation: 0,
              backgroundColor: Colors.blue,
              toolbarHeight: kToolbarHeight,
              expandedHeight: 200,
              flexibleSpace: FlexibleSpaceBar(
                title: Text("Physics not working"),
              ),
            ),
          ),
        ],
        body: Builder(
          builder: (BuildContext context) => CustomScrollView(
            physics: const NeverScrollableScrollPhysics(),
            slivers: <Widget>[
              SliverOverlapInjector(
                handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
              ),
              SliverList(
                delegate: SliverChildBuilderDelegate(
                  (context, index) => Card(
                    child: ListTile(
                      leading: const Icon(Icons.search),
                      title: Text(index.toString()),
                    ),
                  ),
                  childCount: 200,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
Logs
[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-arm, locale fr-FR)
    • Flutter version 3.3.4 on channel stable at /Users/earminjon/fvm/versions/3.3.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (2 weeks ago), 2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/earminjon/Library/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /Users/earminjon/Library/Android/Sdk
    • Java binary at: /Users/earminjon/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • 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.3

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

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/earminjon/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
    • IntelliJ at /Users/earminjon/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 70.2.5
    • Dart plugin version 222.4345.14

[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
    • IntelliJ at /Users/earminjon/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/222.4345.14/IntelliJ IDEA.app
    • 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

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 13 (API 33) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 12.6 21G115 darwin-arm
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 106.0.5249.119

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

• No issues found!

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Oct 20, 2022
  2. exaby73 commented on Oct 20, 2022

    @exaby73
    Member

    Triage report

    I can reproduce this issue on Master (3.5.0-9.0.pre.32)

    Code Sample
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MaterialApp(home: Home()));
    }
    
    class Home extends StatelessWidget {
      const Home({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          backgroundColor: Colors.white,
          body: NestedScrollView(
            physics: const NeverScrollableScrollPhysics(),
            headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) =>
                <Widget>[
              SliverAppBar(
                pinned: true,
                elevation: 0,
                backgroundColor: Colors.blue,
                toolbarHeight: kToolbarHeight,
                expandedHeight: 200,
                flexibleSpace: FlexibleSpaceBar(
                  title: Text("Physics not working"),
                ),
              ),
            ],
            body: CustomScrollView(
              physics: const NeverScrollableScrollPhysics(),
              slivers: <Widget>[
                SliverList(
                  delegate: SliverChildBuilderDelegate(
                    (context, index) => Card(
                      child: ListTile(
                        leading: const Icon(Icons.search),
                        title: Text(index.toString()),
                      ),
                    ),
                    childCount: 200,
                  ),
                ),
              ],
            ),
          ),
        );
      }
    }
  3. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    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 Oct 20, 2022
  4. cer-cer commented on Oct 21, 2022

    @cer-cer

    yes, i also have this problem.

  5. goderbauer commented on Oct 25, 2022

    @goderbauer
    Member
  6. added
    P2Important issues not at the top of the work list
    on Nov 15, 2022
  7. Hynsen commented on Apr 4, 2023

    @Hynsen

    I have the same problem, Has anyone solved this problem?

  8. Piinks commented on Apr 4, 2023

    @Piinks
    Contributor

    I thought this might be related to #45619, but this seems separate from that to me.

  9. Piinks commented on Apr 4, 2023

    @Piinks
    Contributor

    It looks like we apply clamping scroll physics to whatever physics is already supplied:

    final ScrollPhysics scrollPhysics = widget.physics?.applyTo(const ClampingScrollPhysics())

    @xu-baolin has been looking at a similar issue where DraggableScrollableSheet automatically applies AlwaysScrollableScrollPhysics (#121021 | #123109)

  10. self-assigned this
    on Apr 10, 2023
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 12, 2023
  12. github-actions commented on Apr 26, 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.

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

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4frameworkflutter/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 version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions