macosui / macos_ui

Flutter widgets and themes implementing the current macOS design language.
https://macosui.github.io/macos_ui/#/
MIT License
1.87k stars 182 forks source link

MacosPopupButton - ScrollController not attached to any scroll views #309

Closed anilcngz closed 1 year ago

anilcngz commented 2 years ago

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 ```dart 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( value: 'One', onChanged: (String? newValue) {}, items: [ 'One', 'Two', 'Three', 'Four' ].map>((String value) { return MacosPopupMenuItem( value: value, child: Text(value), ); }).toList(), ), const SizedBox(width: 20), MacosPopupButton( 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)
whiplashoo commented 2 years ago

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?

anilcngz commented 2 years ago

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 commented 2 years ago

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.

whiplashoo commented 2 years ago

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?

GroovinChip commented 2 years ago

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.

talkbiz commented 2 years ago

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

jonny7737 commented 2 years ago

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

schilken commented 1 year ago

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

GroovinChip commented 1 year ago

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