samples icon indicating copy to clipboard operation
samples copied to clipboard

FlutterError ShortcutRegistry in cascading_menu_page.dart in Context_Menus

Open RequieMa opened this issue 10 months ago • 2 comments

Exception has occurred. FlutterError (ShortcutRegistry: Received a duplicate registration for the shortcut SingleActivator#39312(keys: Control + Key S) in ShortcutRegistryEntry#64d8f and Instance of 'ShortcutRegistryEntry'.)

Image

RequieMa avatar Feb 24 '25 02:02 RequieMa

I found steps to constantly reproduce this issue:

  1. Run the flutter app in debug mode using vscode
  2. Select Cascading
  3. Right click to show the menu list
  4. Right click again

It seems to be some problem with the dispose method Image with the original code, if I right clicked twice, the ShortcutRegistry.of(context) did not dispose properly, and the same shortcuts were added again. That caused the problem

Image If I verify the length before adding the shortcuts, the problem solved. However, it seems to be a workaround, I did not understand why the dispose did not work properly.

What do you think about this solution? If it is good enough, I will push a merge request

RequieMa avatar Feb 24 '25 03:02 RequieMa

Thanks for reporting and investigating the issue!

@justinmc Could you take a look at this issue and the proposed solution? I appreciate the help :)

parlough avatar Feb 24 '25 20:02 parlough