native_context_menu 0.2.2+5 copy "native_context_menu: ^0.2.2+5" to clipboard
native_context_menu: ^0.2.2+5 copied to clipboard

Provides a native context menu for flutter applications. Most useful on desktop.

native_context_menu #

Native context menu for flutter apps

lesnitsky.dev GitHub stars Twitter Follow

Preview

Installation #

flutter pub add native_context_menu

Usage #

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<App> createState() => _AppState();
}

class _AppState extends State<App> {
  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 GitHub stars Twitter Follow

99
likes
110
pub points
85%
popularity

Publisher

verified publisherlesnitsky.dev

Provides a native context menu for flutter applications. Most useful on desktop.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on native_context_menu