Context Menu for Flutter

Features

  • Single context menu widget that works accross all desktop platforms, mobile platforms and web

  • Can transition to native drag & drop on Android & iOS

1-mobile

  • Native context menu on iOS, macOS and Linux
  • Flutter context menu on Android, Windows and Web

2-desktop

  • Advanced features such as custom lift image, menu and drag preview, deferred menu items (lazy loading) and deferred menu preview

3-mobile

Getting started

super_context_menu uses Rust internally to implement low-level platform specific functionality.

If you don't have Rust installed, the plugin will automatically download precompiled binaries for target platform.

If you want to have the Rust code compiled from source instead, you can install Rust through rustup. The presence of rustup will be detected during build automatically.

For macOS or Linux, execute the following command in Terminal.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

For Windows, you can use the Rust Installer.

In case you have Rust already installed, make sure to update it to latest version:

rustup update

That is it. The build integration will automatically install required Rust targets and other dependencies (NDK). This also means that first build might take a little bit longer.

Usage

Basic example:

  return ContextMenuWidget(
    child: const Item(
    child: Text('Base Context Menu'),
    ),
    menuProvider: (_) {
    return Menu(
        children: [
        MenuAction(title: 'Menu Item 2', callback: () {}),
        MenuAction(title: 'Menu Item 3', callback: () {}),
        MenuSeparator(),
        Menu(title: 'Submenu', children: [
            MenuAction(title: 'Submenu Item 1', callback: () {}),
            MenuAction(title: 'Submenu Item 2', callback: () {}),
            Menu(title: 'Nested Submenu', children: [
            MenuAction(title: 'Submenu Item 1', callback: () {}),
            MenuAction(title: 'Submenu Item 2', callback: () {}),
            ]),
        ]),
        ],
    );
    },
);

Running the example project

Example project is available at super_context_menu/example.

flutter pub global activate melos # if you don't have melos already installed
git clone https://github.com/superlistapp/super_native_extensions.git
cd super_native_extensions
melos bootstrap

After this you can open the folder in VSCode and run the super_context_menu_example launcher configuration.

Libraries

super_context_menu