macos_ui icon indicating copy to clipboard operation
macos_ui copied to clipboard

MacosPopupButton - ScrollController not attached to any scroll views

Open anilcngz opened this issue 3 years ago • 6 comments

When I click on MacosPopupButton, I am getting the following exception:

Unhandled Exception: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 151 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.

macos_ui: ^1.7.5

Code
MacosScaffold(
      toolBar: ToolBar(
        title: const Text('Dependencies'),
        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 SingleChildScrollView(
              padding: const EdgeInsets.all(16.0),
              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      MacosPopupButton<String>(
                        value: 'One',
                        onChanged: (String? newValue) {},
                        items: <String>[
                          'One',
                          'Two',
                          'Three',
                          'Four'
                        ].map<MacosPopupMenuItem<String>>((String value) {
                          return MacosPopupMenuItem<String>(
                            value: value,
                            child: Text(value),
                          );
                        }).toList(),
                      ),
                      const SizedBox(width: 20),
                      MacosPopupButton<String>(
                        disabledHint: const Text("Disabled"),
                        onChanged: null,
                        items: null,
                      ),
                    ],
                  ),
                ],
              ),
            );
          },
        ),
      ],
    );

Logs

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 151 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
package:flutter/…/widgets/scroll_controller.dart:151
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      ScrollController.animateTo
package:flutter/…/widgets/scroll_controller.dart:151
#3      _MacosPopupMenuItemButtonState._handleFocusChange
package:macos_ui/…/buttons/popup_button.dart:57
#4      _FocusState._handleFocusChanged
package:flutter/…/widgets/focus_scope.dart:632
#5      ChangeNotifier.notifyListeners
package:flutter/…/foundation/change_notifier.dart:351
#6      FocusNode._notify
package:flutter/…/widgets/focus_manager.dart:1038
#7      FocusManager._applyFocusChange
package:flutter/…/widgets/focus_manager.dart:1804
#8      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#9      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

anilcngz avatar Oct 06 '22 08:10 anilcngz

Hi @anilcngz, I cannot reproduce this issue with your provided code snippet on Flutter v3.3.3. It seems like an exception thrown by older Flutter versions.

Could you also post your flutter doctor -v?

whiplashoo avatar Oct 06 '22 17:10 whiplashoo

Hi @whiplashoo, below you can find it:

$ flutter doctor -v
[✓] Flutter (Channel stable, 3.3.3, on macOS 12.6 21G115 darwin-arm (Rosetta),
    locale en-TR)
    • Flutter version 3.3.3 on channel stable at
      /Users/anilcengiz/Code/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18a827f393 (8 days ago), 2022-09-28 10:03:14 -0700
    • Engine revision 5c984c26eb
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/anilcengiz/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/anilcengiz/Library/Android/sdk
    • Java binary at: /Users/anilcengiz/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526
      /Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • 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 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-7249189)

[✓] Android Studio (version 2021.2)
    • Android Studio at /Users/anilcengiz/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526
      /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.12+0-b1504.28-7817840)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.6 21G115 darwin-arm
      (Rosetta)
    • Chrome (web)    • chrome • web-javascript • Google Chrome 105.0.5195.125

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

• No issues found!

anilcngz avatar Oct 06 '22 18:10 anilcngz

Hi @whiplashoo, below you can find it:

$ flutter doctor -v
[✓] Flutter (Channel stable, 3.3.3, on macOS 12.6 21G115 darwin-arm (Rosetta),
    locale en-TR)
    • Flutter version 3.3.3 on channel stable at
      /Users/anilcengiz/Code/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18a827f393 (8 days ago), 2022-09-28 10:03:14 -0700
    • Engine revision 5c984c26eb
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/anilcengiz/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/anilcengiz/Library/Android/sdk
    • Java binary at: /Users/anilcengiz/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526
      /Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • 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 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-7249189)

[✓] Android Studio (version 2021.2)
    • Android Studio at /Users/anilcengiz/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526
      /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.12+0-b1504.28-7817840)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.6 21G115 darwin-arm
      (Rosetta)
    • Chrome (web)    • chrome • web-javascript • Google Chrome 105.0.5195.125

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

• No issues found!

Hi @whiplashoo , was this helpful? Please let me know if there is anything I can provide.

anilcngz avatar Oct 10 '22 19:10 anilcngz

I can't reproduce this either with the example app or with your code snippet (with Flutter v3.3.4 and macos_ui v1.7.6). @GroovinChip can you have a look as well?

whiplashoo avatar Oct 11 '22 20:10 whiplashoo

I can't reproduce this either with the example app or with your code snippet (with Flutter v3.3.4 and macos_ui v1.7.6). @GroovinChip can you have a look as well?

I'll give it a shot, yeah.

GroovinChip avatar Oct 11 '22 20:10 GroovinChip

I face the same issue. Kindly fix this bug ASAP.

talkbiz avatar Oct 19 '22 11:10 talkbiz

I have the same issue: Flutter (Channel stable, 3.3.5, on macOS 13.0

jonny7737 avatar Oct 26 '22 00:10 jonny7737

This is already fixed with https://github.com/GroovinChip/macos_ui/pull/300 - but not yet published as 1.7.6 on pub.dev.

schilken avatar Jan 05 '23 17:01 schilken

Hi folks. Apologies for the delay. I'll publish 1.7.6 to pub ASAP.

GroovinChip avatar Jan 14 '23 15:01 GroovinChip