Skip to content

StretchingOverscrollIndicator with AlwaysScrollableScrollPhysics jumps when changing direction #116522

@jankuss

Description

@jankuss

I observed some weird behaviour with the StretchingOverscrollIndicator, which doesn't look right to me. When changing the scroll direction while scrolling, there is a sudden jump - most likely caused by the transform origin of the indicator changing from topCenter to bottomCenter.

I observed this problem only when the content of the Scrollable doesn't fill the Scrollable completely. This is very noticeable when using ListView.builder, or when explicitly setting AlwaysScrollableScrollPhysics on a SingleChildScrollView.

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Trigger the StrechingOverscrollIndicator by pulling your finger down a reasonable distance
  3. Move finger slightly up

Expected results: I expect the overscroll indicator not to jump suddenly. I would have assumed, when moving the finger up again after moving the finger down, it should just do the same but in reverse.

Actual results: There is a sudden jump, which makes the first item in the list display partly outside the bounds of the Scrollable.

Screen.Recording.2022-12-05.at.15.42.34.mov
Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        // Need to set `useMaterial3` to true so we use the stretching overscroll
        // indicator.
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text("StrechingOverscrollIndicator"),
        ),
        body: ListView.builder(
          physics: const AlwaysScrollableScrollPhysics(),
          itemBuilder: (context, index) {
            return Container(
              height: 50,
              color: index % 2 == 0
                  ? const Color(0xFFEEEEEE)
                  : const Color(0xFFCCCCCC),
              child: Text("Index $index"),
            );
          },
          itemCount: 7,
        ),
      ),
    );
  }
}
Logs
Analyzing strech_overscroll_always_scrollable_physics...                
No issues found! (ran in 1.0s)
[✓] Flutter (Channel master, 3.7.0-2.0.pre.40, on macOS 12.2 21D49 darwin-arm64, locale en-DE)
    • Flutter version 3.7.0-2.0.pre.40 on channel master at /Users/kuss/Documents/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4ec4401338 (5 hours ago), 2022-12-05 05:29:27 -0500
    • Engine revision 4de358e2f0
    • Dart version 2.19.0 (build 2.19.0-444.0.dev)
    • DevTools version 2.20.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/kuss/Library/Android/sdk
    • Platform android-33, 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 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.3

[✓] 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)

[✓] IntelliJ IDEA Community Edition (version 2021.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.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

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

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 12 (API 32) (emulator)
    • iPhone 13 (mobile)          • 4F1B2857-3967-4F27-B976-B99A7A41AB96 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 12.2 21D49 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 107.0.5304.121

[✓] HTTP Host Availability
    • All required HTTP hosts 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.3Found to occur in 3.3found 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 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