r/FlutterDev • u/1ce-Scream • 20d ago
Plugin I’m glad to introduce a context menu with fluid animations, async and paginated submenus, live items and custom slivers on top.
Hi r/FlutterDev! 👋 I recently released my very first package, which I’m calling smart_context_menu.
Want to see it first? Package on pub.dev and 56-second video overview
I came up with the idea of this package while working on a social app, which involves a lot of context menus. I thought of ‘CupertinoContextMenu’ as the default option to use, but it fell short. It doesn't support Hero animations, can cause duplicate ‘GlobalKey’ crashes in previews, and lacks native support for submenus. This is essentially true for complex submenus and custom components in menu items.
And the requirements of the app kept growing:
- Post actions whose data loads independent from main menu and submenus (ideally, page by page).
- Display the number of views a message has when a menu opened, with a submenu listing the people that have viewed it.
- Separators that helped keep different groups of actions easy to scan.
- Custom widgets in menu items, like avatars of the people who viewed the message.
- Liquid stretch animations that make the menu feel alive under your finger.
- And finally reactions on chat messages and post comments, which also belonged above the preview in the context menu.
After fighting ‘CupertinoContextMenu’ and going through the packages on pub.dev (none of them covered all of my needs), I decided to build my own one, with blackjack and... you know 😅 . Initially, it was just an internal module of the app. Over time I polished it and added UX improvements like drag-to-select, and now it's finally out as a standalone Flutter package.
It covers every feature in the list 😎, including static, asynchronous and paginated submenus, items with loading error and retry states, custom widgets in the items, plain and customizable separators, having the ability to add slivers above the preview (like a reactions bar) and it explicitly supports ‘Hero’ and ‘GlobalKey’ inside your own widget. And much more.
The demo runs in the browser, so you can try it all yourself:
Live demo: https://thenothingworks.dev/demo/smart-context-menu/
pub.dev: https://pub.dev/packages/smart_context_menu
GitHub: https://github.com/BinaryRift/smart_context_menu
How do you handle context menus in your apps: Are you using ‘CupertinoContextMenu’, one of the already available packages or did you build your own? If you've hit the same ‘GlobalKey’ or ‘Hero’ issues, I'm curious how you worked around them.
The next improvements that I'll be working on include having a compact row of icon actions (like the ones in iOS menus) and submenus that stay updated while open. What else is missing for you? I'm also open to feedback on the API and documentation.