Skip to content

MacosPopupButton - ScrollController not attached to any scroll views #309

@anilcngz

Description

@anilcngz

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)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions