Repository navigation
Description
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 deprecatingContextMenuButtonType): IntroduceContextMenuButtonKind(includingtranslate) andContextMenuButtonItem.kind, while keepingContextMenuButtonTypeandContextMenuButtonItem.typeundeprecated. (Add ContextMenuButtonKind #193528) - 2. Migrate
cupertino_uiandmaterial_ui: OnceContextMenuButtonKindreaches stable, bump the minimum Flutter SDK incupertino_uiandmaterial_uiand switch them fromitem.typetoitem.kind(including handlingtranslate). - 3. Deprecate
ContextMenuButtonTypeandContextMenuButtonItem.type
Activity
2 remaining items
[-]Migrate ContextMenuButtonType to an enum-like class[/-][+]Migrate ContextMenuButtonType to an enum-like class ContextMenuButtonKind[/+]Add ContextMenuButtonKind (flutter#193528)
[CP-stable]Add ContextMenuButtonKind (#195015)
Add ContextMenuButtonKind (flutter#193528)
[CP-beta]Add ContextMenuButtonKind (#195922)
[CP-stable]Add ContextMenuButtonKind (#195015)
[CP-stable]Add ContextMenuButtonKind (#195015)
[CP-stable]Add ContextMenuButtonKind (#195015)