https://github.com/lesnitsky/native_context_menu
Native context menu for Flutter apps
https://github.com/lesnitsky/native_context_menu
flutter flutter-desktop flutter-macos
Last synced: 12 days ago
JSON representation
Native context menu for Flutter apps
- Host: GitHub
- URL: https://github.com/lesnitsky/native_context_menu
- Owner: lesnitsky
- License: mit
- Created: 2021-09-14T14:09:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T13:59:39.000Z (about 2 years ago)
- Last Synced: 2025-03-24T08:43:26.561Z (22 days ago)
- Topics: flutter, flutter-desktop, flutter-macos
- Language: C++
- Homepage: https://pub.dev/packages/native_context_menu
- Size: 149 KB
- Stars: 167
- Watchers: 4
- Forks: 26
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flutter-desktop - native_context_menu - Provides a native context menu for flutter applications. Most useful on desktop. (Packages)
README
# native_context_menu
Native context menu for flutter apps
[](https://lesnitsky.dev?utm_source=native_context_menu)
[](https://github.com/lesnitsky/native_context_menu)
[](https://twitter.com/lesnitsky_dev)
## Installation
```bash
flutter pub add native_context_menu
```## Usage
```dart
import 'package:native_context_menu/native_context_menu.dart';
import 'package:flutter/material.dart';void main() {
runApp(App());
}class App extends StatefulWidget {
const App({Key? key}) : super(key: key);@override
State createState() => _AppState();
}class _AppState extends State {
String? action;@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: ContextMenuRegion(
onDismissed: () => setState(() => action = 'Menu was dismissed'),
onItemSelected: (item) => setState(() {
action = '${item.title} was selected';
}),
menuItems: [
MenuItem(title: 'First item'),
MenuItem(title: 'Second item'),
MenuItem(
title: 'Third item with submenu',
items: [
MenuItem(title: 'First subitem'),
MenuItem(title: 'Second subitem'),
MenuItem(title: 'Third subitem'),
],
),
MenuItem(title: 'Fourth item'),
],
child: Card(
child: Center(
child: Text(action ?? 'Right click me'),
),
),
),
),
);
}
}
```## Platform support
| Platform | Supported |
| -------- | --------- |
| MacOS | ✅ |
| Linux | ✅ |
| Windows | ✅ |## License
MIT
---
[](https://lesnitsky.dev?utm_source=native_context_menu)
[](https://github.com/lesnitsky/native_context_menu)
[](https://twitter.com/lesnitsky_dev)