Skip to content

Assert in ScrollbarPainter on scroll with trackpad #149803

@tgucio

Description

@tgucio

Steps to reproduce

  1. Run flutter create and replace main.dart with the provided code sample.
  2. Run on macOS making sure the window is larger than the ListView with 5 elements so there's no real scroll.
  3. Do a scroll gesture over the ListView using the trackpad

Expected results

Nothing happens.

Actual results

LateInitializationError assert is shown:

════════ Exception caught by gesture ═══════════════════════════════════════════
The following LateError was thrown while handling a gesture:
LateInitializationError: Field '_thumbExtent@528211710' has not been initialized.

When the exception was thrown, this was the stack:
#0      ScrollbarPainter._thumbExtent (package:flutter/src/widgets/scrollbar.dart)
#1      ScrollbarPainter.getThumbScrollOffset (package:flutter/src/widgets/scrollbar.dart:662:54)
#2      RawScrollbarState.handleThumbPressStart (package:flutter/src/widgets/scrollbar.dart:1695:46)
#3      _MaterialScrollbarState.handleThumbPressStart (package:flutter/src/material/scrollbar.dart:360:11)
#4      RawScrollbarState._handleThumbDragStart (package:flutter/src/widgets/scrollbar.dart:1919:5)
#5      DragGestureRecognizer._checkStart.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:785:53)
#6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:344:24)
#7      DragGestureRecognizer._checkStart (package:flutter/src/gestures/monodrag.dart:785:7)
#8      DragGestureRecognizer._checkDrag (package:flutter/src/gestures/monodrag.dart:752:5)
#9      DragGestureRecognizer.acceptGesture (package:flutter/src/gestures/monodrag.dart:679:7)
#10     GestureArenaManager._resolveByDefault (package:flutter/src/gestures/arena.dart:269:25)
#11     GestureArenaManager._tryToResolveArena.<anonymous closure> (package:flutter/src/gestures/arena.dart:249:31)
(elided 2 frames from dart:async)

Handler: "onStart"
Recognizer: _VerticalThumbDragGestureRecognizer#3233f
    debugOwner: _MaterialScrollbarState#f529f(tickers: tracking 2 tickers)
    start behavior: down
════════════════════════════════════════════════════════════════════════════════

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final ScrollController _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('Scroll me'),
            Expanded(
              child: Scrollbar(
                controller: _scrollController,
                child: ScrollConfiguration(
                  behavior: ScrollConfiguration.of(context).copyWith(
                    scrollbars: false,
                    physics: const BouncingScrollPhysics(),
                  ),
                  child: ListView(
                    controller: _scrollController,
                    children: List<ListTile>.generate(5, (index) => ListTile(title: Text('Tile $index'), onTap: () => print('tap!'))),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

No response

Flutter Doctor output

Doctor output
% flutter doctor -v
[✓] Flutter (Channel master, 3.23.0-13.0.pre.121, on macOS 14.5 23F79 darwin-arm64, locale en-ES)
    • Flutter version 3.23.0-13.0.pre.121 on channel master at /Users/tgucio/Library/Frameworks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4608a89137 (5 hours ago), 2024-06-06 08:11:25 +0200
    • Engine revision 92d0cd9370
    • Dart version 3.5.0 (build 3.5.0-227.0.dev)
    • DevTools version 2.36.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/tgucio/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.2)
    • 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 17.0.9+0-17.0.9b1087.7-11185874)

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: desktopRunning on desktopa: error messageError messages from the Flutter frameworkc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowfound in release: 3.23Found to occur in 3.23frameworkflutter/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 teamwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions