Skip to content

Commit

Permalink
Fix PlatformMenuItems with onSelectedIntent are never enabled (flutte…
Browse files Browse the repository at this point in the history
…r#121885)

Fix PlatformMenuItems with onSelectedIntent are never enabled
  • Loading branch information
jmatth authored Mar 7, 2023
1 parent 91dea4d commit 8557ffa
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 123 deletions.
8 changes: 5 additions & 3 deletions packages/flutter/lib/src/widgets/platform_menu_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ class PlatformMenuItem with Diagnosticable {
/// An optional callback that is called when this [PlatformMenuItem] is
/// selected.
///
/// If unset, this menu item will be disabled.
/// At most one of [onSelected] and [onSelectedIntent] may be set. If neither
/// field is set, this menu item will be disabled.
final VoidCallback? onSelected;

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

/// Returns all descendant [PlatformMenuItem]s of this item.
Expand Down Expand Up @@ -805,7 +807,7 @@ class PlatformMenuItem with Diagnosticable {
return <String, Object?>{
_kIdKey: getId(item),
_kLabelKey: item.label,
_kEnabledKey: item.onSelected != null,
_kEnabledKey: item.onSelected != null || item.onSelectedIntent != null,
if (shortcut != null)...shortcut.serializeForMenu().toChannelRepresentation(),
};
}
Expand Down
Loading

0 comments on commit 8557ffa

Please sign in to comment.