Skip to content

fix: MenuFlyout TypeError on findRenderObject in sub-item hover handler#1306

Merged
bdlukaa merged 2 commits intomasterfrom
copilot/fix-menu-flyout-type-error
Mar 6, 2026
Merged

fix: MenuFlyout TypeError on findRenderObject in sub-item hover handler#1306
bdlukaa merged 2 commits intomasterfrom
copilot/fix-menu-flyout-type-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

MenuFlyout throws a TypeError at runtime because findRenderObject is referenced as a method tearoff instead of being called. Bug introduced in 838f520.

// before — gets Function reference, fails cast to RenderBox
parent.widget.root!.context.findRenderObject as RenderBox;

// after — calls method, null-asserts the result
parent.widget.root!.context.findRenderObject()! as RenderBox;
  • Fix: Added missing ()! on findRenderObject call in menu_flyout.dart line 156, matching the identical pattern on line 154
  • Test: Added widget test that opens a MenuFlyoutSubItem, triggers sub-menu via hover, then moves mouse away to exercise the fixed code path
  • Changelog: Added entry under [next]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • chrome-infra-packages.appspot.com
    • Triggering command: /usr/bin/curl curl -sIL REDACTED bash 742c�� /cache (dns block)
  • dart.dev
    • Triggering command: /usr/bin/curl curl -sL -w %{http_code} REDACTED -o /dev/null (dns block)
  • https://storage.googleapis.com/flutter_infra_release/flutter/18818009497c581ede5d8a3b8b833b81d00cebb7/dart-sdk-linux-x64.zip
    • Triggering command: /usr/bin/curl curl --retry 3 --continue-at - --location --output /tmp/flutter/bin/cache/dart-sdk-linux-x64.zip REDACTED (http block)
    • Triggering command: /usr/bin/curl curl -sIL REDACTED (http block)
  • https://storage.googleapis.com/flutter_infra_release/flutter/18818009497c581ede5d8a3b8b833b81d00cebb7/linux-x64-debug/linux-x64-flutter-gtk.zip
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot precache --linux /home/REDACTED/.pub-cache/_temp/dirGZDXJG/test/_files/is_executable.sh (http block)
  • https://storage.googleapis.com/flutter_infra_release/flutter/18818009497c581ede5d8a3b8b833b81d00cebb7/linux-x64/font-subset.zip
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get erator.early erator.late de/node/bin/chmod (http block)
  • https://storage.googleapis.com/flutter_infra_release/flutter/18818009497c581ede5d8a3b8b833b81d00cebb7/sky_engine.zip
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get _REDACTED.sh (http block)
    • Triggering command: /usr/bin/curl curl -sIL REDACTED irt --po�� vis.sh --preprocess (http block)
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get --version (http block)
  • https://storage.googleapis.com/flutter_infra_release/flutter/e4b8dca3f1b4ede4c30371002441c88c12187ed6/dart-sdk-linux-x64.zip
    • Triggering command: /usr/bin/curl curl --retry 3 --continue-at - --location --output /tmp/flutter/bin/cache/dart-sdk-linux-x64.zip REDACTED (http block)
  • https://storage.googleapis.com/flutter_infra_release/flutter/fonts/3012db47f3130e62f7cc0beabff968a33cbec8d8/fonts.zip
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get (http block)
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get /home/REDACTED/work/_temp/runtime-logs/command.sh (http block)
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get origin REDACTED (http block)
  • https://storage.googleapis.com/flutter_infra_release/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get get --local hfs credential.helpebash (http block)
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart --packages=/tmp/flutter/packages/flutter_tools/.dart_tool/package_config.json /tmp/flutter/bin/cache/flutter_tools.snapshot pub get REDACTED (http block)
  • https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json
    • Triggering command: /snap/flutter/current/usr/bin/curl curl -o releases_linux.json REDACTED (http block)
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart pub --suppress-analytics get --suppress-analytics --example --directory . (http block)
    • Triggering command: /tmp/flutter/bin/cache/dart-sdk/bin/dart /tmp/flutter/bin/cache/dart-sdk/bin/dart pub --suppress-analytics --color --directory . get --example (http block)
  • https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.32.0-stable.tar.xz
    • Triggering command: /usr/bin/curl curl -sL REDACTED -o flutter.tar.xz (http block)
    • Triggering command: /usr/bin/curl curl -sIL REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>🐛 Menu Flyout throws _TypeError Exception</issue_title>
<issue_description>MenuFlyout throws an exception because it can't cast the findRenderObject method as a RenderBox.

The error is at line 156 of /lib/src/controls/flyouts/menu_flyout.dart

Has:

final parentBox = parent.widget.root!.context.findRenderObject as RenderBox;

Should be

final parentBox = parent.widget.root!.context.findRenderObject()! as RenderBox;

Bug was introduced with 838f520

Thanks for a great project!</issue_description>

<agent_instructions>Add tests and update the changelog at the end</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…andler

Fix TypeError in MenuFlyout by changing `findRenderObject` (method tearoff)
to `findRenderObject()!` (method call with null assertion) on line 156 of
menu_flyout.dart. Added test for MenuFlyoutSubItem hover behavior and
updated CHANGELOG.

Co-authored-by: bdlukaa <45696119+bdlukaa@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix menu flyout TypeError exception fix: MenuFlyout TypeError on findRenderObject in sub-item hover handler Mar 5, 2026
@bdlukaa bdlukaa marked this pull request as ready for review March 5, 2026 16:27
@bdlukaa
Copy link
Copy Markdown
Owner

bdlukaa commented Mar 5, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a TypeError in MenuFlyout that occurred when a sub-item's hover handler was triggered. The issue was caused by referencing findRenderObject as a method tearoff instead of calling it. The fix adds the missing function call (), which resolves the runtime error. Additionally, a new widget test has been added to specifically cover this scenario, ensuring the bug is fixed and preventing future regressions. The changelog has also been updated accordingly. The changes are correct and well-implemented.

@bdlukaa bdlukaa merged commit 4adafe3 into master Mar 6, 2026
1 check failed
solbirn added a commit to owlxcorp/fluent_ui that referenced this pull request Apr 28, 2026
Resolved conflicts:
- pubspec.yaml: bumped to 4.15.1+1 (upstream 4.15.1 with +1 fork suffix)
- menu_flyout.dart: kept upstream's findRenderObject()! null-assertion fix
  (PR bdlukaa#1306 - MenuFlyout TypeError on findRenderObject)
- tree_view.dart: kept upstream's _children = List.of(children) initializer
  (PR bdlukaa#1297 - Add TreeViewController with programmatic reordering)

Brings in 30 upstream commits including TreeViewController, RTL fixes for
MenuFlyout/ProgressBar/NumberBox, NavigationView negative-constraint fix,
TitleBar height fix, and VisualDensity-based compact sizing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Menu Flyout throws _TypeError Exception

2 participants