Skip to content
pubscout

contextmenu

3.0.0, released 5 years ago by braid.business

Display a beautifully animated, material context menu using pure Flutter

WASM-ready
$ flutter pub add contextmenu
Source repository

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.

Works with

Packages commonly used together with contextmenu: ones it builds on, ones built on it, and its own family.