context_menu_android 1.0.5
context_menu_android: ^1.0.5 copied to clipboard
iOS-style context menu widget for Flutter with blur, smooth animations, and nested sub-menus; optimized for Android.
π ios_style_context_menu #
A Flutter package that brings the elegant iOS-style context menu experience to Android β complete with blur effects, fluid animations, and nested sub-menus.
Perfect for creating beautiful long-press menus on any widget, such as cards, images, or list items β all with the finesse of Apple design.
β¨ Why ios_style_context_menu? #
| Feature | Description |
|---|---|
| π True iOS Feel | Replicates iOSβs smooth context menu interaction, animations, and visual hierarchy. |
| π§© Fully Customizable | Adjust text, icons, colors, padding, and animation curves β effortlessly. |
| π« Smooth Transitions | Powered by Flutter animations and BackdropFilter for silky blur effects. |
| πͺ Nested Menus Support | Easily create sub-menus with back navigation β ideal for complex actions. |
| π Dark & Light Themes | Automatically adapts to the system theme or use isDark to override. |
| π§ Smart Delete Detection | Destructive actions (like βDeleteβ) are automatically highlighted in red. |
| βοΈ Performance-Optimized | Uses efficient animation controllers and responsive sizing for any screen. |
π Getting Started #
Add to your project:
dependencies:
ios_style_context_menu: ^1.0.5
Then run:
flutter pub get
Import it in your code:
import 'package:ios_style_context_menu/ios_style_context_menu.dart';
π§ Basic Usage #
Wrap any widget with IosStyleContextMenu and pass a list of actions:
IosStyleContextMenu(
child: Image.network('https://picsum.photos/200'),
actions: [
ContextMenuAndroid(
icon: Icons.share,
label: 'Share',
onTap: () => print('Shared!'),
),
ContextMenuAndroid(
icon: Icons.favorite,
label: 'Add to Favorites',
onTap: () => print('Added to favorites!'),
),
ContextMenuAndroid(
icon: Icons.delete,
label: 'Delete',
onTap: () => print('Deleted!'),
),
],
);
πΏ Advanced Example with Sub-Menus #
IosStyleContextMenu(
child: Card(
elevation: 6,
child: ListTile(
leading: Icon(Icons.movie),
title: Text('Inception'),
subtitle: Text('Tap & hold for menu'),
),
),
actions: [
ContextMenuAndroid(
icon: Icons.play_arrow,
label: 'Play',
onTap: () => print('Playing Inception...'),
),
ContextMenuAndroid(
icon: Icons.more_horiz,
label: 'More',
subMenu: [
ContextMenuAndroid(
icon: Icons.info_outline,
label: 'Details',
onTap: () => print('Opening details...'),
),
ContextMenuAndroid(
icon: Icons.download,
label: 'Download',
onTap: () => print('Downloading...'),
),
],
),
],
);
βοΈ Customization Options #
| Property | Type | Description |
|---|---|---|
child |
Widget |
Required. The widget that triggers the context menu. |
actions |
List<ContextMenuAndroid> |
Required. A list of action items, each with icon, label, and callback. |
isDark |
bool? |
Forces dark mode (if not set, it follows system theme). |
textStyle |
TextStyle? |
Custom text style for action labels. |
backgroundColor |
Color? |
Background color of the menu container (defaults based on theme). |
dividerColor |
Color? |
Divider color between menu items. |
iconColor |
Color? |
Icon color (automatically turns red for βDeleteβ actions). |
contentPadding |
EdgeInsetsGeometry? |
Padding around the menu container. |
textSize |
double? |
Font size for text, scales responsively. |
iconSize |
double? |
Optional icon size (currently unused by default). |
πΈ Live Preview #
π§± Architecture Overview #
lib/
βββ ios_style_context_menu.dart # Core widget and animations
βββ context_menu.dart # Data model for menu actions
βββ src/
βββ animations/
βββ widgets/
βββ utils/
π‘ Pro Tips #
- β
Use
Navigator.pop(context)manually only if you wrap custom dialogs inside. - π You can open nested sub-menus dynamically using
subMenuproperty. - π¨ Combine with
Theme.of(context)for adaptive color matching. - πΉ Long-press gesture wrappers can be added for auto-open menus.
π§° Planned Add-ons (v2.0) #
- β¨ Built-in long-press wrapper (
IosContextMenuWrapper). - π Haptic feedback for tap and open events.
- π¬ Custom animation styles (fade, slide, scale).
- π§© Public theme configuration class (
ContextMenuThemeData).
π License #
This project is licensed under the MIT License.
Youβre free to use, modify, and distribute it with proper attribution.
β€οΈ Credits #
Developed and maintained with π by
Omar Shawkey
"Design like Apple. Animate like Flutter." π
