contextmenu
3.0.0, released 5 years ago by braid.business
Display a beautifully animated, material context menu using pure Flutter
What it does
Displays an animated material context menu that works on both touch and desktop devices. It handles screen edges and oversize automatically. Developers can use the ContextMenuArea widget or trigger it manually.
AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to add a context menu to cards, text, or other widgets
- You want a context menu that handles screen edges and touch or desktop devices
Skip it when
- You are using a non-Material design system
- You require complex platform-specific native context menu integrations
Strengths
- Modern, animation-focused Material Design implementation
- Works on both touch and desktop devices
- Very efficient and lightweight code base
Weaknesses
- Requires manual configuration on web via index.html to disable native right-click menus
- Limited to Material design style
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
For web platforms, you must add `oncontextmenu="return false;"` in the `<body>` tag of your index.html.
Widget build() {
return ContextMenuArea(
builder: (context) => [
ListTile(
title: Text('Option 1'),
onTap: () {
Navigator.of(context).pop();
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Whatever')));
},
)
],
child: Card(
child: Center(
child: Text('Press somewhere for context menu.'),
),
),
);
}Alternatives
Packages that do the same job and could replace contextmenu.
- flutter_speed_dial
Flutter plugin to implement a Material Design Speed Dial with labels and animated icons.
92Compare - flutter_context_menu
Create and display customizable context menus with hierarchical submenus in Flutter apps.
66Compare - super_context_menu
Context menu widget supporting native menus on platforms and drag & drop transitions on mobile.
76Compare - material_new_shapes
Provides Material 3 shape definitions (e.g., RoundedPolygon, Cubic) for Flutter UI.
48Compare
Works with
Packages commonly used together with contextmenu: ones it builds on, ones built on it, and its own family.