Skip to content

Potential regression of #108298 after Flutter 3.7.0 upgrade #119323

@GroovinChip

Description

@GroovinChip

After upgrading to Flutter 3.7.0, applications using macos_ui are seeing several The Scrollbar's ScrollController has no ScrollPosition attached. errors, without any indication of which Scrollbars and/or Scrollables are the source of the trace in question.

CC @Piinks @moffatman

Steps to Reproduce

Optional: Perform this process on macOS for maximum reproduction reliability (applications written with macos_ui can run on Windows & Linux but it is not recommended)

  1. Ensure you are on the latest stable branch
  2. Create a new Flutter app (ensuring that the macOS runner is present)
  3. Run flutter pub add macos_ui
  4. Replace all code in main.dart with the code found in the "Code sample" section below
  5. Targeting macOS, execute flutter run on the aforementioned code sample
  6. Upon the launch of the app, without attempting to scroll, observe three errors in the console that report The Scrollbar's ScrollController has no ScrollPosition attached.. Note that none of the stack traces report which Scrollbar and/or Scrollable widget from macos_ui is the source of the particular trace.

Expected results:
Prior to #108298 arriving with Flutter 3.7.0, none of the errors being reported here were present. I suppose I expected things to remain that way.

Actual results:
No visual errors, just stack traces in the console.

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MacosApp(
      title: 'scrollable_bug',
      theme: MacosThemeData.light(),
      darkTheme: MacosThemeData.dark(),
      themeMode: ThemeMode.system,
      home: const MainView(),
      debugShowCheckedModeBanner: true,
    );
  }
}

class MainView extends StatefulWidget {
  const MainView({super.key});

  @override
  State<MainView> createState() => _MainViewState();
}

class _MainViewState extends State<MainView> {
  int _pageIndex = 0;

  @override
  Widget build(BuildContext context) {
    return MacosWindow(
      sidebar: Sidebar(
        minWidth: 200,
        builder: (context, scrollController) => SidebarItems(
          currentIndex: _pageIndex,
          onChanged: (index) {
            setState(() => _pageIndex = index);
          },
          items: const [
            SidebarItem(
              leading: MacosIcon(CupertinoIcons.home),
              label: Text('Home'),
            ),
          ],
        ),
      ),
      child: IndexedStack(
        index: _pageIndex,
        children: const [
          HomePage(),
        ],
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Builder(
      builder: (context) {
        return MacosScaffold(
          toolBar: ToolBar(
            title: const Text('Home'),
            actions: [
              ToolBarIconButton(
                label: 'Toggle Sidebar',
                icon: const MacosIcon(CupertinoIcons.sidebar_left),
                showLabel: false,
                tooltipMessage: 'Toggle Sidebar',
                onPressed: () {
                  MacosWindowScope.of(context).toggleSidebar();
                },
              )
            ],
          ),
          children: [
            ContentArea(
              builder: (context, scrollController) {
                return const Center(
                  child: Text('Home'),
                );
              },
            ),
          ],
        );
      },
    );
  }
}
Logs
Launching lib/main.dart on macOS in debug mode...
Building macOS application...
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00008103-000970CE0CE2001E }
{ platform:macOS, arch:x86_64, id:00008103-000970CE0CE2001E }
Debug service listening on ws://127.0.0.1:57150/EIvWoM3zb5s=/ws
Syncing files to device macOS...

======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
The Scrollbar's ScrollController has no ScrollPosition attached.

A Scrollbar cannot be painted without a ScrollPosition. 

The Scrollbar attempted to use the provided ScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to.When providing your own ScrollController, ensure both the Scrollbar and the Scrollable widget use the same one.

When the exception was thrown, this was the stack: 
#0      RawScrollbarState._debugCheckHasValidScrollPosition.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:1597:9)
#1      RawScrollbarState._debugCheckHasValidScrollPosition (package:flutter/src/widgets/scrollbar.dart:1622:6)
#2      RawScrollbarState._debugScheduleCheckHasValidScrollPosition.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:1551:14)
#3      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#4      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1227:9)
#5      SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:942:7)
#9      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)
(elided 3 frames from class _Timer and dart:async-patch)
====================================================================================================

======== Exception caught by animation library =====================================================
The following assertion was thrown while notifying status listeners for AnimationController:
The Scrollbar's ScrollController has no ScrollPosition attached.

A Scrollbar cannot be painted without a ScrollPosition. 

The Scrollbar attempted to use the provided ScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to.When providing your own ScrollController, ensure both the Scrollbar and the Scrollable widget use the same one.

When the exception was thrown, this was the stack: 
#0      RawScrollbarState._debugCheckHasValidScrollPosition.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:1597:9)
#1      RawScrollbarState._debugCheckHasValidScrollPosition (package:flutter/src/widgets/scrollbar.dart:1622:6)
#2      RawScrollbarState._validateInteractions (package:flutter/src/widgets/scrollbar.dart:1564:14)
#3      AnimationLocalStatusListenersMixin.notifyStatusListeners (package:flutter/src/animation/listener_helpers.dart:240:19)
#4      AnimationController._checkStatusChanged (package:flutter/src/animation/animation_controller.dart:822:7)
#5      AnimationController._startSimulation (package:flutter/src/animation/animation_controller.dart:756:5)
#6      AnimationController._animateToInternal (package:flutter/src/animation/animation_controller.dart:619:12)
#7      AnimationController.forward (package:flutter/src/animation/animation_controller.dart:467:12)
#8      RawScrollbarState._handleScrollMetricsNotification (package:flutter/src/widgets/scrollbar.dart:1938:37)
#9      _NotificationElement.onNotification (package:flutter/src/widgets/notification_listener.dart:130:38)
#10     _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3170:18)
#11     _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3173:13)
#12     _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3173:13)
#13     _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3173:13)
#14     _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3173:13)
#15     Element.dispatchNotification (package:flutter/src/widgets/framework.dart:4534:24)
#16     Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:60:13)
#17     ScrollPosition.didUpdateScrollMetrics (package:flutter/src/widgets/scroll_position.dart:947:93)
(elided 2 frames from dart:async)
The AnimationController notifying status listeners was: AnimationController#9c725(▶ 0.000)
====================================================================================================

======== Exception caught by animation library =====================================================
The following assertion was thrown while notifying status listeners for AnimationController:
The Scrollbar's ScrollController has no ScrollPosition attached.

A Scrollbar cannot be painted without a ScrollPosition. 

The Scrollbar attempted to use the provided ScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to.When providing your own ScrollController, ensure both the Scrollbar and the Scrollable widget use the same one.

When the exception was thrown, this was the stack: 
#0      RawScrollbarState._debugCheckHasValidScrollPosition.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:1597:9)
#1      RawScrollbarState._debugCheckHasValidScrollPosition (package:flutter/src/widgets/scrollbar.dart:1622:6)
#2      RawScrollbarState._validateInteractions (package:flutter/src/widgets/scrollbar.dart:1564:14)
#3      AnimationLocalStatusListenersMixin.notifyStatusListeners (package:flutter/src/animation/listener_helpers.dart:240:19)
#4      AnimationController._checkStatusChanged (package:flutter/src/animation/animation_controller.dart:822:7)
#5      AnimationController._tick (package:flutter/src/animation/animation_controller.dart:838:5)
#6      Ticker._tick (package:flutter/src/scheduler/ticker.dart:249:12)
#7      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#8      SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1140:11)
#9      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#10     SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:1138:17)
#11     SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:1055:5)
#12     _invoke1 (dart:ui/hooks.dart:164:13)
#13     PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:316:5)
#14     _beginFrame (dart:ui/hooks.dart:101:31)
The AnimationController notifying status listeners was: AnimationController#9c725(⏭ 1.000; paused)
====================================================================================================
reubenturner@Reubens-MacBook-Pro-M1 scrollable_bug % flutter analyze
Analyzing scrollable_bug...                                             
No issues found! (ran in 1.8s)
[✓] Flutter (Channel stable, 3.7.0, on macOS 12.4 21F79 darwin-arm64, locale en-US)
    • Flutter version 3.7.0 on channel stable at /Users/reubenturner/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (3 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/reubenturner/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • 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 2020.3)
    • 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.10+0-b96-7281165)

[✓] IntelliJ IDEA Community Edition (version 2022.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 71.3.6
    • Dart plugin version 223.8214.16

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.4 21F79 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 109.0.5414.119

[✓] 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.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions