popup_menu_2 0.1.7
popup_menu_2: ^0.1.7 copied to clipboard
A popup menu containing clickable buttons, each with a global click function referring to the item. This is designed to avoid breaking the user's attention.
Lightweight and customizable Flutter popup menus designed to keep user attention on the current context.
π Watch the demo web release | π¦ Download the latest APK
This is a fork of popup_menu by @chinabrant #
β¨ Highlights #
- Context-aware popup positioning.
- Supports both tap and long-press triggers.
- Grid-style menu with configurable columns.
- Dismiss-on-click-away behavior.
- Works across Flutter-supported platforms.
πΈ Preview #
π¦ Installation #
Add dependency to your pubspec.yaml:
dependencies:
popup_menu_2: ^0.1.6
Then run:
flutter pub get
π Quick Start #
ContextualMenu #
import 'package:flutter/material.dart';
import 'package:popup_menu_2/popup_menu_2.dart';
final GlobalKey targetKey = GlobalKey();
ContextualMenu(
targetWidgetKey: targetKey,
maxColumns: 2,
dismissOnClickAway: true,
backgroundColor: Colors.black87,
items: [
ContextPopupMenuItem(
onTap: () async {},
child: const Icon(Icons.add, color: Colors.white),
),
ContextPopupMenuItem(
onTap: () async {},
child: const Icon(Icons.remove, color: Colors.white),
),
],
child: Icon(Icons.more_vert, key: targetKey),
)
CustomPopupMenu + Controller #
import 'package:flutter/material.dart';
import 'package:popup_menu_2/popup_menu_2.dart';
final controller = CustomPopupMenuController();
CustomPopupMenu(
controller: controller,
pressType: PressType.singleClick,
menuBuilder: () => Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: const Text('Hello from popup_menu_2'),
),
child: const Icon(Icons.touch_app),
)
βοΈ Core Options #
ContextualMenu:maxColumns,dismissOnClickAway,position,backgroundColor,highlightColor,lineColor.CustomPopupMenu:pressType,showArrow,arrowColor,barrierColor,position,menuOnChange,enablePassEvent.
π License #
Distributed under the BSD 3-Clause license. See LICENSE.
π More Packages #
π¨βπ» Developer Card #
Younes M'rabti #
π§ Email: admin@youmti.net
π Website: youmti.net
πΌ LinkedIn: younesmrabti1996