Skip to content

[beta] Cherry pick https://github.com/flutter/flutter/pull/181074#181367

Merged
auto-submit[bot] merged 1 commit intoflutter:flutter-3.41-candidate.0from
dkwingsmt:cp-181074
Jan 27, 2026
Merged

[beta] Cherry pick https://github.com/flutter/flutter/pull/181074#181367
auto-submit[bot] merged 1 commit intoflutter:flutter-3.41-candidate.0from
dkwingsmt:cp-181074

Conversation

@dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Jan 23, 2026

This PR cherrypicks #181074 into beta, which is mostly a revert of #176711 (except that some docs are left unreverted and a few new tests are added.) This is needed to address a breakage as described in #180121.

Impacted Users: Apps that use DropdownMenu or DropdownMenuFormField for a nullable class, such as DropdownMenu<int?>.

Impact Description: Can not compile.

Workaround: Yes, through non-trivial changes. For example, the developer can replace DropdownMenu<int?> with DropdownMenu<Maybe<int>>, as long as they import Maybe or create their own equivalence.

Risk: Low. This PR is basically a revert.

Test Coverage: Yes. The widget has high test coverage.

Validation Steps: The PR compiles and tests pass.

@flutter-dashboard
Copy link

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jan 23, 2026
Copy link
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 is a cherry-pick to fix a regression preventing the use of nullable types with DropdownMenu and DropdownMenuFormField. The changes correctly remove the extends Object constraint on the generic type parameter T for these widgets and their corresponding states. New regression tests have been added to ensure that nullable types, including selecting a null value, work as expected. The changes are sound and directly address the issue. I have one minor suggestion to improve code quality in the tests by reducing some duplication.

Comment on lines +35 to +41
Finder findMenuItemButton(String label) {
// For each menu items there are two MenuItemButton widgets.
// The last one is the real button item in the menu.
// The first one is not visible, it is part of _DropdownMenuBody
// which is used to compute the dropdown width.
return find.widgetWithText(MenuItemButton, label).last;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This new helper function findMenuItemButton is very similar to the existing findMenuItem function in this file. To avoid code duplication and improve maintainability, consider refactoring findMenuItem to call this new, more generic function.

For example, you could change findMenuItem to:

  Finder findMenuItem(MenuItem menuItem) {
    return findMenuItemButton(menuItem.label);
  }

This would also allow you to remove the duplicated comment from findMenuItem.

Copy link
Contributor

@Gustl22 Gustl22 Jan 23, 2026

Choose a reason for hiding this comment

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

I originally thought about this, but decided to keep both methods to not need a refactor in a "revert" PR and keep the method in sync with the conventions in dropdown_menu_test.dart. We could do a follow-up refactor, if desired.

@dkwingsmt dkwingsmt added the cp: review Cherry-picks in the review queue label Jan 23, 2026
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

The revert LGTM. But I don't think the original commit has reached stable: 0205d4e. So can you confirm that this is a CP to beta?

await tester.tap(findMenuItemButton(selectNoneLabel));
await tester.pumpAndSettle();

expect(controller.text, selectNoneLabel);
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh I thought the text should be empty or something since the widget uses null for "no selection"?

Copy link
Contributor

@Gustl22 Gustl22 Jan 27, 2026

Choose a reason for hiding this comment

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

What exactly is the difference? Only the label? Is that something we can integrate in #181369, but still merge this cherry pick?

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

@dkwingsmt dkwingsmt changed the title [stable] Cherry pick https://github.com/flutter/flutter/pull/181074 [beta] Cherry pick https://github.com/flutter/flutter/pull/181074 Jan 27, 2026
@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 27, 2026
@auto-submit auto-submit bot merged commit f3c54a6 into flutter:flutter-3.41-candidate.0 Jan 27, 2026
141 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jan 28, 2026
Resolves
#181367 (comment)

The test was still valid as `DropdownMenuFormField` includes
`DropdownMenu` and therefore could select the desired MenuItemButton.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
Resolves
flutter#181367 (comment)

The test was still valid as `DropdownMenuFormField` includes
`DropdownMenu` and therefore could select the desired MenuItemButton.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: review Cherry-picks in the review queue f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants