Desktop Context Menu
A package that spawns a context menu at the mouse coordinates.
Available for MacOS, Windows and Linux.
Hotkeys available only for MacOS.
Platform Support
Linux | macOS | Windows |
---|---|---|
✔️ | ✔️ | ✔️ |
Screenshots
macOS | Linux | Windows |
---|---|---|
Quick Start
Installation
Add this to your package's pubspec.yaml file:
dependencies:
flutter_desktop_context_menu: ^0.2.0
Usage
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_desktop_context_menu/flutter_desktop_context_menu.dart';
Menu menu = Menu(
items: [
MenuItem(
label: 'Copy',
shortcutKey: 'c',
shortcutModifiers: ShortcutModifiers(
control: Platform.isWindows, meta: Platform.isMacOS),
onClick: (_) {
print('Clicked Copy');
},
),
MenuItem(
label: 'Disabled item',
disabled: true,
),
MenuItem.checkbox(
key: 'checkbox1',
label: 'Checkbox1',
toolTip: 'Checkbox 1',
checked: true,
onClick: (menuItem) {
print('Clicked Checkbox1');
menuItem.checked = !(menuItem.checked == true);
},
),
MenuItem.separator(),
],
);
popUpContextualMenu(
menu,
placement: Placement.bottomLeft,
);
Please see the example app of this plugin for a full example.