Skip to content

Implement CupertinoMenu and CupertinoNestedMenu - #137936

Closed
davidhicks980 wants to merge 23 commits into
flutter:masterfrom
davidhicks980:cupertino_menu
Closed

davidhicks980 wants to merge 23 commits into
flutter:masterfrom
davidhicks980:cupertino_menu

Conversation

@davidhicks980

@davidhicks980 davidhicks980 commented Nov 6, 2023 •

Copy link
Copy Markdown
Contributor

Resolves #60298, notDmDrl/pull_down_button#26

This PR adds a CupertinoMenu, CupertinoNestedMenu, and associated widgets that increase feature parity with iOS.

I'm submitting a draft PR to collect feedback on the overall API and layout design before writing more extensive layout and API tests. I have added a few tests based on the PopupMenu widget, and I've done some manual accessibility testing across iOS, Android, and MacOS. Comments and an example have been added, but could use review. I also added TODO annotations for any particularly pressing questions I have.

I'm still fairly new to Flutter, so I apologize for any unconventional code. Let me know if there are any pieces we need to tear out or rethink. I'm interested to hear different ideas regarding how to solve this menu, so I appreciate you all taking a look!

Also, I used @notDmDrl's repo as a base for my contributions: https://github.com/notDmDrl/pull_down_button, so I'm not sure whether I should contact him with regards to signing a CLA.

Basic example:

import 'package:flutter/cupertino.dart';

/// Flutter code sample for [CupertinoMenuButton]
void main() => runApp(const CupertinoMenuApp());
class CupertinoMenuApp extends StatelessWidget {
  const CupertinoMenuApp({super.key});
  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      theme: CupertinoThemeData(brightness: Brightness.light),
      home: CupertinoMenuExample(),
    );
  }
}

class CupertinoMenuExample extends StatefulWidget {
  const CupertinoMenuExample({super.key});

  @override
  State<CupertinoMenuExample> createState() => _CupertinoMenuExampleState();
}

class _CupertinoMenuExampleState extends State<CupertinoMenuExample> {
  String _checkedValue = 'Cat';
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: const CupertinoNavigationBar(
        middle: Text('CupertinoMenu Sample'),
      ),
      child: Align(
        alignment: Alignment(0, -0.5),
        child: SizedBox(
          width: 100,
          height: 100,
          child:  CupertinoMenuButton<String>(
            itemBuilder: (BuildContext context) {
              return <CupertinoMenuEntry<String>>[
                CupertinoStickyMenuHeader(
                  leading: Container(
                    width: 42,
                    height: 42,
                    decoration:  ShapeDecoration(
                      shape: CircleBorder(),
                      gradient: LinearGradient(
                        begin: Alignment.topCenter,
                        end: Alignment.bottomCenter,
                        colors: <Color>[
                          CupertinoColors.activeBlue,
                          CupertinoColors.activeBlue.withOpacity(0.5),
                        ],
                      ),
                    ),
                  ),
                  trailing: CupertinoButton(
                    minSize: 34,
                    padding: EdgeInsets.zero,
                    child: Container(
                      width: 34,
                      height: 34,
                      decoration: ShapeDecoration(
                        shape: const CircleBorder(),
                        color: CupertinoColors.systemFill.resolveFrom(context),
                      ),
                      child: Icon(
                        CupertinoIcons.share,
                        color: CupertinoColors.label.resolveFrom(context),
                        size: 16,
                        semanticLabel: 'Triangle',
                      ),
                    ),
                    onPressed: () {},
                  ),
                  subtitle: const Text('Folder'),
                  child: const Text('Downloads'),
                ),
                CupertinoNestedMenu<String>(
                  itemBuilder: (BuildContext context) => <CupertinoMenuEntry<String>>[
                    CupertinoCheckedMenuItem<String>(
                      value: 'Cat',
                      checked: _checkedValue == 'Cat',
                      shouldPopMenuOnPressed: false,
                      onTap: (){
                        setState(() {
                          _checkedValue = 'Cat';
                        });
                      },
                      child: const Text('Cat'),
                    ),
                    CupertinoCheckedMenuItem<String>(
                      value: 'Feline',
                      checked: _checkedValue == 'Feline',
                      onTap: (){
                        setState(() {
                          _checkedValue = 'Feline';
                        });
                      },
                      shouldPopMenuOnPressed: false,
                      child: const Text('Feline'),
                    ),
                    CupertinoCheckedMenuItem<String>(
                      value: 'Kitten',
                      checked: _checkedValue == 'Kitten',
                      onTap: (){
                        setState(() {
                          _checkedValue = 'Kitten';
                        });
                      },
                      shouldPopMenuOnPressed: false,
                      child: const Text('Kitten'),
                    ),
                  ],
                  subtitle:  Text(_checkedValue),
                  title: const TextSpan(text: 'Favorite Animal'),
                ),
                CupertinoMenuItem<String>(
                  trailing: const Icon(
                    CupertinoIcons.textformat_size,
                  ),
                  child: const Text(
                    'Simple',
                  ),
                  onTap: () {},
                ),
                const CupertinoMenuItem<String>(
                  shouldPopMenuOnPressed: false,
                  trailing: Icon(
                    CupertinoIcons.textformat_size,
                  ),
                  isDefaultAction: true,
                  child: Text('Default'),
                ),
                const CupertinoMenuItem<String>(
                  trailing: Icon(CupertinoIcons.cloud_upload),
                  value: 'Disabled',
                  enabled: false,
                  child: Text('Disabled'),
                ),
                const CupertinoMenuActionItem<String>(
                  icon: Icon(
                    CupertinoIcons.triangle,
                    semanticLabel: 'Triangle',
                  ),
                  value: 'Triangle',
                  child: Text('Triangle'),
                ),
                const CupertinoMenuActionItem<String>(
                  icon: Icon(
                    CupertinoIcons.square,
                    semanticLabel: 'Square',
                  ),
                  value: 'Square',
                  child: Text('Square'),
                ),
                const CupertinoMenuActionItem<String>(
                  icon: Icon(
                    CupertinoIcons.circle,
                    semanticLabel: 'Circle',
                  ),
                  value: 'Circle',
                  child: Text('Circle'),
                ),
                const CupertinoMenuActionItem<String>(
                  icon: Icon(
                    CupertinoIcons.star,
                    semanticLabel: 'Star',
                  ),
                  value: 'Star',
                  child: Text('Star'),
                ),
                const CupertinoMenuLargeDivider(),
                const CupertinoMenuItem<String>(
                  value: 'Delete',
                  isDestructiveAction: true,
                  trailing: Icon(
                    CupertinoIcons.delete,
                    semanticLabel: 'Delete',
                  ),
                  child: Text('Delete'),
                ),
              ];
            },
          ),
        ),
      ),
    );
  }
}
Screen.Recording.2023-11-06.at.7.00.25.AM.mov

@MitchellGoodwin

Pre-launch Checklist

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

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

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Nov 6, 2023
@MitchellGoodwin

Copy link
Copy Markdown
Contributor

Thank you very much for putting this together! I'll block out some time to go through the design.

On basing it off of the pull_down_package, that might be fine, but the most foolproof way to make the lawyers happy is if @notDmDrl was willing to sign a CLA. If not, that's perfectly fine and we can see what guidance is available.

@notDmDrl

notDmDrl commented Nov 7, 2023

Copy link
Copy Markdown

@MitchellGoodwin @davidhicks980 I signed CLA

@MitchellGoodwin

Copy link
Copy Markdown
Contributor

@MitchellGoodwin @davidhicks980 I signed CLA

Thank you!

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Welcome @davidhicks980

Comment thread packages/flutter/lib/src/cupertino/menu.dart Outdated
@Hixie

Hixie commented Nov 10, 2023

Copy link
Copy Markdown
Contributor

@notDmDrl just for the complete avoidance of doubt, can you confirm whether you are ok with this code landing with the usual Flutter license and copyright rather than your MIT license and copyright?

@notDmDrl

Copy link
Copy Markdown

@Hixie, yes, I am ok with it :)

If there is anything that needs to be done with my package for this PR to land, please let me know

@davidhicks980

Copy link
Copy Markdown
Contributor Author

Thanks @Piinks and team for taking a look and giving feedback! I'm still moving things around and fixing issues so I appreciate you all directing me towards any code I may have forgotten to prune. Also, some features that were missing have since been added -- in particular, sticky submenu headers. Whenever I have a moment, I'll draft up an overview of the mechanics of the menu in case any of my comments are ambiguous.

Screen.Recording.2023-11-12.at.7.34.06.AM.mov

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As this is still a draft I have not been through it entirely, but I wanted to ask:

  1. Why should this be in the framework instead of in a separate package? We typically ask this in so far as weighing the maintenance burden of adopting this into the framework.
  2. Can it be split up into multiple PRs so it is easier to review? I think I saw mention of different features that have been added here. Landing a basic version and adding features in follow up PRs might be easier to do, since reviewers can better focus on one aspect at a time rather than everything all at once.

@Void48

Void48 commented Jan 24, 2024

Copy link
Copy Markdown

@davidhicks980 Thanks for the work! Looking forward to it

@JaidynBluesky

Copy link
Copy Markdown

Any update on this? Would love for some way to try this out in the interim @davidhicks980, this is just what I need for my app.

@davidhicks980

davidhicks980 commented Feb 20, 2024 •

Copy link
Copy Markdown
Contributor Author

@JaidynBluesky If you need all of the features right now, you should be able to copy the menu_item.dart and the menu.dart: https://github.com/flutter/flutter/blob/6bd90293300da86e31d9f0644c5e21a8e52c1a82/packages/flutter/lib/src/cupertino/menu.dart
and
https://github.com/flutter/flutter/blob/6bd90293300da86e31d9f0644c5e21a8e52c1a82/packages/flutter/lib/src/cupertino/menu_item.dart .

Just place menu.dart and menu_item.dart in your project folder and replace the local imports with a single "import package:flutter/cupertino":

/// In menu.dart + menu_item.dart

/// Replace this: 
import 'colors.dart';
import 'constants.dart';
import 'icons.dart';

/// With this
import 'package:flutter/cupertino.dart';

From there, you should just be able to import like any other file:

/// Import from wherever you copied the files
import 'menu_item.dart';
import 'menu.dart';

///.... Use like any other widget

CupertinoMenuButton<int>(
    itemBuilder: (BuildContext context) {
      return <CupertinoMenuEntry<int>>[
       const CupertinoMenuItem<int>(value: 1, child: Text('A')),
       const CupertinoMenuItem<int>(value: 2, child: Text('B')),
       const CupertinoMenuItem<int>(value: 3, child: Text('C')),
        CupertinoNestedMenu<int>(
          itemBuilder: (BuildContext context) {
            return [
                 const CupertinoMenuItem<int>(value: 1, child: Text('D')),
                 const CupertinoMenuItem<int>(value: 2, child: Text('E')),
                 const CupertinoMenuItem<int>(value: 3, child: Text('F')),
            ];
          },
          subtitle: const Text('Subtitle'),
          title: const TextSpan(text: 'Nested Menu'),
        ),
      ];
    },
    child: Icon(CupertinoIcons.plus, size: 24)
  );
///....

(I'm not on a device I can test at the moment, so sorry in advance for any errors you may encounter. Let me know if anything is complicated though):

That said, if you only need a simple menu with a single layer of items, the new version based on MenuAnchor will probably be closer to the final version of the menu, and has many more tests:
#143712

@Piinks

Piinks commented Apr 23, 2024

Copy link
Copy Markdown
Contributor

Hey @davidhicks980, we just came across this in triage today. Is #143712 meant to replace this PR? If so, should we close this?

@davidhicks980

Copy link
Copy Markdown
Contributor Author

@Piinks - yes to both! I'll go ahead and close.

@davidhicks980 davidhicks980 mentioned this pull request Nov 14, 2024
9 tasks done
github-merge-queue Bot pushed a commit that referenced this pull request Feb 6, 2026
…using RawMenuAnchor (#174695)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`,
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves #60298,
notDmDrl/pull_down_button#26,
#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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
github-merge-queue Bot pushed a commit that referenced this pull request Feb 6, 2026
…MenuItem using RawMenuAnchor (#174695)" (#182010)

<!-- start_original_pr_link -->
Reverts: #174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves #60298,
notDmDrl/pull_down_button#26,
#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
…using RawMenuAnchor (flutter#174695)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`,
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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
…MenuItem using RawMenuAnchor (flutter#174695)" (flutter#182010)

<!-- start_original_pr_link -->
Reverts: flutter#174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

flutter#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
…using RawMenuAnchor (flutter#174695)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`,
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
…MenuItem using RawMenuAnchor (flutter#174695)" (flutter#182010)

<!-- start_original_pr_link -->
Reverts: flutter#174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

flutter#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
chunhtai pushed a commit to chunhtai/flutter that referenced this pull request Feb 27, 2026
…MenuItem using RawMenuAnchor (flutter#174695)" (flutter#182010)

<!-- start_original_pr_link -->
Reverts: flutter#174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…using RawMenuAnchor (flutter#174695)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`,
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…MenuItem using RawMenuAnchor (flutter#174695)" (flutter#182010)

<!-- start_original_pr_link -->
Reverts: flutter#174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

flutter#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
github-merge-queue Bot pushed a commit that referenced this pull request Apr 8, 2026
…using RawMenuAnchor (#182036)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves #60298,
notDmDrl/pull_down_button#26,
#137936.



https://github.com/user-attachments/assets/cdaee8da-888b-4f64-8bf3-49c873f6d6e1


Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

----

Edit: Reland of #174695 after
revert #182010 due to breakage
when tests were randomized.

Per @jason-simmons -
> The error seen on CI can be reproduced by running:
> flutter test --test-randomize-ordering-seed=20260206
test/cupertino/menu_anchor_test.dart

Thanks to those who caught the error -- sorry I didn't notice.

From what I can deduce, two errors were present.

**Test 1: Menus do not close on root menu internal scroll (and others)**
The first error occurred due to TestPointers being created with an
existing pointer number. This was fixed by using tester.nextPointer
instead of a fixed number.

Code:
https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L968

```dart
    final pointer = TestPointer(
       1, // Fixed with tester.nextPointer
       ui.PointerDeviceKind.mouse
    );
    await tester.sendEventToBinding(pointer.hover(tester.getCenter(find.text(Tag.a.text))));
    await tester.pump();
```

**Test 2: `Menu scale rebounds to full size when swipe gesture ends`**

The second error occurred due to the _SwipeRegion's GestureRecognizer
outliving its state and calling didSwipeLeave on a disposed
CupertinoMenuItem. <s>This shouldn't be a problem -- swiping is supposed
to continue so long as a user has their pointer down -- but the
CupertinoMenuItem should have checked whether it was mounted before
entering code that could schedule a rebuild (e.g. _handleActivation,
isSwiped)</s> Nevermind -- I realize now there isn't much of a reason
for letting the swipe outlive the region, so I just disposed of the
swipe when the SwipeRegion is unmounted. I still kept the mounted check.

Code:

https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L1285

```dart
@OverRide
void didSwipeLeave({bool pointerUp = false}) {
    // This function could be called after disposal, but _handleActivation and isSwiped both could trigger rebuilds. 
    // Fix:
    // if (!mounted) {
    //   return
    // }

    if (isEnabled && pointerUp) {
      _handleActivation();
    }

    isSwiped = false;
  }
```

I ran an additional 500 randomized menu_anchor_test.dart runs and did
not experience another exception. I believe everything should be
good-to-go, but I'll pay closer attention to cocoon.

---

## 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.
- [x] 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
mbcorona pushed a commit to mbcorona/flutter that referenced this pull request Apr 15, 2026
…using RawMenuAnchor (flutter#182036)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter#60298,
notDmDrl/pull_down_button#26,
flutter#137936.



https://github.com/user-attachments/assets/cdaee8da-888b-4f64-8bf3-49c873f6d6e1


Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

----

Edit: Reland of flutter#174695 after
revert flutter#182010 due to breakage
when tests were randomized.

Per @jason-simmons -
> The error seen on CI can be reproduced by running:
> flutter test --test-randomize-ordering-seed=20260206
test/cupertino/menu_anchor_test.dart

Thanks to those who caught the error -- sorry I didn't notice.

From what I can deduce, two errors were present.

**Test 1: Menus do not close on root menu internal scroll (and others)**
The first error occurred due to TestPointers being created with an
existing pointer number. This was fixed by using tester.nextPointer
instead of a fixed number.

Code:
https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L968

```dart
    final pointer = TestPointer(
       1, // Fixed with tester.nextPointer
       ui.PointerDeviceKind.mouse
    );
    await tester.sendEventToBinding(pointer.hover(tester.getCenter(find.text(Tag.a.text))));
    await tester.pump();
```

**Test 2: `Menu scale rebounds to full size when swipe gesture ends`**

The second error occurred due to the _SwipeRegion's GestureRecognizer
outliving its state and calling didSwipeLeave on a disposed
CupertinoMenuItem. <s>This shouldn't be a problem -- swiping is supposed
to continue so long as a user has their pointer down -- but the
CupertinoMenuItem should have checked whether it was mounted before
entering code that could schedule a rebuild (e.g. _handleActivation,
isSwiped)</s> Nevermind -- I realize now there isn't much of a reason
for letting the swipe outlive the region, so I just disposed of the
swipe when the SwipeRegion is unmounted. I still kept the mounted check.

Code:

https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L1285

```dart
@OverRide
void didSwipeLeave({bool pointerUp = false}) {
    // This function could be called after disposal, but _handleActivation and isSwiped both could trigger rebuilds. 
    // Fix:
    // if (!mounted) {
    //   return
    // }

    if (isEnabled && pointerUp) {
      _handleActivation();
    }

    isSwiped = false;
  }
```

I ran an additional 500 randomized menu_anchor_test.dart runs and did
not experience another exception. I believe everything should be
good-to-go, but I'll pay closer attention to cocoon.

---

## 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.
- [x] 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
chunhtai pushed a commit to chunhtai/packages that referenced this pull request Jun 12, 2026
…using RawMenuAnchor (#174695)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`,
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter/flutter#60298,
notDmDrl/pull_down_button#26,
flutter/flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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
chunhtai pushed a commit to chunhtai/packages that referenced this pull request Jun 12, 2026
…MenuItem using RawMenuAnchor (#174695)" (#182010)

<!-- start_original_pr_link -->
Reverts: flutter/flutter#174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

flutter#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter/flutter#60298,
notDmDrl/pull_down_button#26,
flutter/flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
chunhtai pushed a commit to chunhtai/packages that referenced this pull request Jun 12, 2026
…using RawMenuAnchor (#182036)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter/flutter#60298,
notDmDrl/pull_down_button#26,
flutter/flutter#137936.



https://github.com/user-attachments/assets/cdaee8da-888b-4f64-8bf3-49c873f6d6e1


Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

----

Edit: Reland of flutter/flutter#174695 after
revert flutter/flutter#182010 due to breakage
when tests were randomized.

Per @jason-simmons -
> The error seen on CI can be reproduced by running:
> flutter test --test-randomize-ordering-seed=20260206
test/cupertino/menu_anchor_test.dart

Thanks to those who caught the error -- sorry I didn't notice.

From what I can deduce, two errors were present.

**Test 1: Menus do not close on root menu internal scroll (and others)**
The first error occurred due to TestPointers being created with an
existing pointer number. This was fixed by using tester.nextPointer
instead of a fixed number.

Code:
https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L968

```dart
    final pointer = TestPointer(
       1, // Fixed with tester.nextPointer
       ui.PointerDeviceKind.mouse
    );
    await tester.sendEventToBinding(pointer.hover(tester.getCenter(find.text(Tag.a.text))));
    await tester.pump();
```

**Test 2: `Menu scale rebounds to full size when swipe gesture ends`**

The second error occurred due to the _SwipeRegion's GestureRecognizer
outliving its state and calling didSwipeLeave on a disposed
CupertinoMenuItem. <s>This shouldn't be a problem -- swiping is supposed
to continue so long as a user has their pointer down -- but the
CupertinoMenuItem should have checked whether it was mounted before
entering code that could schedule a rebuild (e.g. _handleActivation,
isSwiped)</s> Nevermind -- I realize now there isn't much of a reason
for letting the swipe outlive the region, so I just disposed of the
swipe when the SwipeRegion is unmounted. I still kept the mounted check.

Code:

https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L1285

```dart
@OverRide
void didSwipeLeave({bool pointerUp = false}) {
    // This function could be called after disposal, but _handleActivation and isSwiped both could trigger rebuilds. 
    // Fix:
    // if (!mounted) {
    //   return
    // }

    if (isEnabled && pointerUp) {
      _handleActivation();
    }

    isSwiped = false;
  }
```

I ran an additional 500 randomized menu_anchor_test.dart runs and did
not experience another exception. I believe everything should be
good-to-go, but I'll pay closer attention to cocoon.

---

## 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.
- [x] 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
Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 2026
…using RawMenuAnchor (#174695)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`,
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter/flutter#60298,
notDmDrl/pull_down_button#26,
flutter/flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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
Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 2026
…MenuItem using RawMenuAnchor (#174695)" (#182010)

<!-- start_original_pr_link -->
Reverts: flutter/flutter#174695
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: post submits are broken

Please do not directly add to the merge queue until all presubmits pass.

#21 main.<anonymous closure>
(file:///C:/b/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/menu_anchor_test.dart:969:18)

<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: davidhicks980
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {dkwingsmt}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter/flutter#60298,
notDmDrl/pull_down_button#26,
flutter/flutter#137936.


https://github.com/user-attachments/assets/551f2169-cac4-4078-890b-6728ab9c2ae5

Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

## 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.
- [x] 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

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 2026
…using RawMenuAnchor (#182036)

This PR implements `CupertinoMenuAnchor`, `CupertinoMenuItem`, and
`CupertinoMenuDivider` using `RawMenuAnchor`.

Resolves flutter/flutter#60298,
notDmDrl/pull_down_button#26,
flutter/flutter#137936.



https://github.com/user-attachments/assets/cdaee8da-888b-4f64-8bf3-49c873f6d6e1


Dartpad: https://dartpad.dev/8c6bba779b6a00e95582b61b132292bc

@dkwingsmt 

----

Edit: Reland of flutter/flutter#174695 after
revert flutter/flutter#182010 due to breakage
when tests were randomized.

Per @jason-simmons -
> The error seen on CI can be reproduced by running:
> flutter test --test-randomize-ordering-seed=20260206
test/cupertino/menu_anchor_test.dart

Thanks to those who caught the error -- sorry I didn't notice.

From what I can deduce, two errors were present.

**Test 1: Menus do not close on root menu internal scroll (and others)**
The first error occurred due to TestPointers being created with an
existing pointer number. This was fixed by using tester.nextPointer
instead of a fixed number.

Code:
https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L968

```dart
    final pointer = TestPointer(
       1, // Fixed with tester.nextPointer
       ui.PointerDeviceKind.mouse
    );
    await tester.sendEventToBinding(pointer.hover(tester.getCenter(find.text(Tag.a.text))));
    await tester.pump();
```

**Test 2: `Menu scale rebounds to full size when swipe gesture ends`**

The second error occurred due to the _SwipeRegion's GestureRecognizer
outliving its state and calling didSwipeLeave on a disposed
CupertinoMenuItem. <s>This shouldn't be a problem -- swiping is supposed
to continue so long as a user has their pointer down -- but the
CupertinoMenuItem should have checked whether it was mounted before
entering code that could schedule a rebuild (e.g. _handleActivation,
isSwiped)</s> Nevermind -- I realize now there isn't much of a reason
for letting the swipe outlive the region, so I just disposed of the
swipe when the SwipeRegion is unmounted. I still kept the mounted check.

Code:

https://github.com/davidhicks980/flutter/blob/054f3b03f2ab04822760c600e4259fbd828ebd4d/packages/flutter/test/cupertino/menu_anchor_test.dart#L1285

```dart
@OverRide
void didSwipeLeave({bool pointerUp = false}) {
    // This function could be called after disposal, but _handleActivation and isSwiped both could trigger rebuilds. 
    // Fix:
    // if (!mounted) {
    //   return
    // }

    if (isEnabled && pointerUp) {
      _handleActivation();
    }

    isSwiped = false;
  }
```

I ran an additional 500 randomized menu_anchor_test.dart runs and did
not experience another exception. I believe everything should be
good-to-go, but I'll pay closer attention to cocoon.

---

## 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.
- [x] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pull-Down Menus for iOS 14

8 participants