Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 26 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 (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T13:59:39.000Z (almost 2 years ago)
- Last Synced: 2024-10-04T02:57:22.518Z (about 1 month ago)
- Topics: flutter, flutter-desktop, flutter-macos
- Language: C++
- Homepage: https://pub.dev/packages/native_context_menu
- Size: 149 KB
- Stars: 165
- Watchers: 5
- Forks: 25
- 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
[![lesnitsky.dev](https://lesnitsky.dev/shield.svg?hash=69464)](https://lesnitsky.dev?utm_source=native_context_menu)
[![GitHub stars](https://img.shields.io/github/stars/lesnitsky/native_context_menu.svg?style=social)](https://github.com/lesnitsky/native_context_menu)
[![Twitter Follow](https://img.shields.io/twitter/follow/lesnitsky_dev.svg?label=Follow%20me&style=social)](https://twitter.com/lesnitsky_dev)![Preview](https://lesnitsky-images.s3.eu-north-1.amazonaws.com/native_context_menu.gif)
## 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
---
[![lesnitsky.dev](https://lesnitsky.dev/shield.svg?hash=69464)](https://lesnitsky.dev?utm_source=native_context_menu)
[![GitHub stars](https://img.shields.io/github/stars/lesnitsky/native_context_menu.svg?style=social)](https://github.com/lesnitsky/native_context_menu)
[![Twitter Follow](https://img.shields.io/twitter/follow/lesnitsky_dev.svg?label=Follow%20me&style=social)](https://twitter.com/lesnitsky_dev)