Skip to content

Commit 8557ffa

Browse files
authored
Fix PlatformMenuItems with onSelectedIntent are never enabled (#121885)
Fix PlatformMenuItems with onSelectedIntent are never enabled
1 parent 91dea4d commit 8557ffa

File tree

2 files changed

+171
-123
lines changed

2 files changed

+171
-123
lines changed

packages/flutter/lib/src/widgets/platform_menu_bar.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ class PlatformMenuItem with Diagnosticable {
738738
/// An optional callback that is called when this [PlatformMenuItem] is
739739
/// selected.
740740
///
741-
/// If unset, this menu item will be disabled.
741+
/// At most one of [onSelected] and [onSelectedIntent] may be set. If neither
742+
/// field is set, this menu item will be disabled.
742743
final VoidCallback? onSelected;
743744

744745
/// Returns a callback, if any, to be invoked if the platform menu receives a
@@ -760,7 +761,8 @@ class PlatformMenuItem with Diagnosticable {
760761
/// An optional intent that is invoked when this [PlatformMenuItem] is
761762
/// selected.
762763
///
763-
/// If unset, this menu item will be disabled.
764+
/// At most one of [onSelected] and [onSelectedIntent] may be set. If neither
765+
/// field is set, this menu item will be disabled.
764766
final Intent? onSelectedIntent;
765767

766768
/// Returns all descendant [PlatformMenuItem]s of this item.
@@ -805,7 +807,7 @@ class PlatformMenuItem with Diagnosticable {
805807
return <String, Object?>{
806808
_kIdKey: getId(item),
807809
_kLabelKey: item.label,
808-
_kEnabledKey: item.onSelected != null,
810+
_kEnabledKey: item.onSelected != null || item.onSelectedIntent != null,
809811
if (shortcut != null)...shortcut.serializeForMenu().toChannelRepresentation(),
810812
};
811813
}

0 commit comments

Comments
 (0)