You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is that on Windows, state and enabled need to be set after adding the item to the menu. Here's the fix for your code:
WidgettestTextWithContextMenu({
bool checked =true,
}) {
returnGestureDetector(
onSecondaryTap: () {
final menu =Menu();
final checkableItem =MenuItem("Checkable", MenuItemType.checkbox);
final disabledItem =MenuItem("Disabled");
menu.addItem(checkableItem);
menu.addItem(disabledItem);
// 👇 Set state and enabled AFTER addItem
checkableItem.state = checked
?MenuItemState.checked
:MenuItemState.unchecked;
disabledItem.enabled =false;
menu.open(PositioningStrategy.cursorPosition());
},
child:Text("Right-click on me"),
);
}
Just move the property assignments after addItem() and it should work on Windows.
We'll also fix the underlying issue in the Windows native implementation so that setting these properties before addItem() works as expected in a future release.
Activity
lijy91 commentedon May 12, 2026
Hey @pharan,
The issue is that on Windows,
stateandenabledneed to be set after adding the item to the menu. Here's the fix for your code:Just move the property assignments after
addItem()and it should work on Windows.We'll also fix the underlying issue in the Windows native implementation so that setting these properties before
addItem()works as expected in a future release.lijy91 commentedon May 12, 2026
The root cause has been documented in detail in issue #5, and a fix has been applied in the Windows native code.
Fix Windows menu item state and enabled properties ignored before add…
Add .gitattributes and menu example enhancements