Skip to content

Migrate ContextMenuButtonType to an enum-like class ContextMenuButtonKind #193527

Open

Description

@LouiseHsu

ContextMenuButtonType is a public enum in package:flutter/widgets.dart. cupertino_ui and material_ui (and probably other packages and apps) use exhaustive switches over it, so adding a new value is a breaking change. For example, adding ContextMenuButtonType.translate breaks the published cupertino_ui 1.1.1.

This is blocking the iOS Translate context menu item (#180021). The engine side already landed in #189878, but the framework side can't add a new button type without breaking the decoupled packages.
The Dart team isn't planning to add open enums (dart-lang/sdk#63678 (comment)), so the suggestion from the discussion was to move to an enum-like class, like we did with FloatingActionButtonLocation.

Because cupertino_ui and material_ui support older stable Flutter versions, they can't reference ContextMenuButtonKind until it reaches stable and they bump their minimum SDK constraint. To avoid unresolvable deprecation warnings on master in the meantime, we're doing a phased migration:

  • 1. Add ContextMenuButtonKind (without deprecating ContextMenuButtonType): Introduce ContextMenuButtonKind (including translate) and ContextMenuButtonItem.kind, while keeping ContextMenuButtonType and ContextMenuButtonItem.type undeprecated. (Add ContextMenuButtonKind #193528)
  • 2. Migrate cupertino_ui and material_ui: Once ContextMenuButtonKind reaches stable, bump the minimum Flutter SDK in cupertino_ui and material_ui and switch them from item.type to item.kind (including handling translate).
  • 3. Deprecate ContextMenuButtonType and ContextMenuButtonItem.type

Activity

  1. added
    P3Issues that are less important to the Flutter project
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    and removed
    c: proposalA detailed proposal for a change to Flutter
    P3Issues that are less important to the Flutter project
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    on Oct 6, 2026
  2. 2 remaining items

  3. added
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    P3Issues that are less important to the Flutter project
    and removed
    p: cupertino_uicupertino_ui package in flutter/packages
    on Oct 6, 2026
  4. changed the title [-]Migrate ContextMenuButtonType to an enum-like class[/-] [+]Migrate ContextMenuButtonType to an enum-like class ContextMenuButtonKind[/+] on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions