Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled Menu Item #11

Open
sanihaq opened this issue Nov 30, 2021 · 2 comments
Open

Disabled Menu Item #11

sanihaq opened this issue Nov 30, 2021 · 2 comments

Comments

@sanihaq
Copy link

sanihaq commented Nov 30, 2021

There should be a disabled state for menu item when no function is passed.

@edwardaux
Copy link

FWIW, I needed this recently so added it in my local fork with this commit: edwardaux@3c2f5c4

A couple of important notes:

  • There's an onSelected function on MenuItem that doesn't seem like it is used at the moment. It was a bit unclear what the difference was designed to be between this callback and onItemSelected in ContextMenuRegion. My assumption is that I'd use the former if I wanted different functions to be called back for each item, and I'd use the latter if I just wanted to have one function (and if both were present, then both would be called). However, as I mentioned, MenuItem.onSelected isn't currently hooked up, so I had to add a call to ContextMenuRegion to make sure it calls both.
  • For my personal needs, I adopted the Flutter convention of disabling the widget if the onSelected function is not set. However, this would be a breaking change for any current users of this library (all menu items would be disabled unless they were setting the onSelected in their MenuItem objects - which they wouldn't be because those callbacks don't currently get called)
  • I'm happy to raise a PR back here if @lesnitsky would like, however a) I think the caveats above may mean that it is a breaking change, and b) I don't have a windows or a linux machine to be able to do a similar thing.

In any event, I just thought I'd share in case anyone else needed to do something similar.

@lesnitsky
Copy link
Owner

lesnitsky commented Apr 15, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants