flex_menu_button 0.0.3
flex_menu_button: ^0.0.3 copied to clipboard
A flexible and customizable dropdown menu button for Flutter. Supports headers, footers, icon or text triggers, custom styles, tooltips, and even secret invisible actions.
π½ flex_menu_button #
A customizable and lightweight Flutter dropdown menu button designed to be used in AppBars, Toolbars, or anywhere you want quick access to menu actions. It supports icons, text, headers, footers, dividers, custom widgets, flexible alignment, and full style control.
Features #
π Works out of the box β no dependencies
πCustom icon, label, text styles
πOptional header and footer widgets
πDropdown alignment and screen-side flipping
πCustom width, max height, padding, and scrolling
πOptional custom widgets, dividers, and trailing elements
πTooltip customization
πFully modular, easy to extend
Installation #
Add this to your pubspec.yaml:
dependencies:
flex_menu_button: ^<latest_version>
Then run:
flutter pub get
π 1. Basic Usage #
MenuDropdownButton(
tooltip: 'Options',
icon: Icons.more_vert,
items: [
MenuItem(icon: Icons.edit, label: 'Edit', onTap: () {}),
MenuItem(icon: Icons.delete, label: 'Delete', onTap: () {}),
],
)
πΈ Screenshot:
[Basic Usage]
π 2. Menu Alignment Options #
MenuDropdownButton(
tooltip: 'Align Center',
icon: Icons.more_horiz,
config: MenuDropdownConfig(
alignment: MenuAlignment.center,
),
items: [
MenuItem(icon: Icons.share, label: 'Share', onTap: () {}),
MenuItem(icon: Icons.link, label: 'Copy Link', onTap: () {}),
],
)
πΈ Screenshot:
[Menu Alignment]
π 3. Header & Footer #
MenuDropdownButton(
tooltip: 'Menu with Header/Footer',
icon: Icons.menu,
header: Padding(
padding: EdgeInsets.all(8),
child: Text('Header: Account Actions', style: TextStyle(color: Colors.white)),
),
footer: Padding(
padding: EdgeInsets.all(8),
child: Text('Footer: Version 1.0.0', style: TextStyle(color: Colors.grey)),
),
items: [
MenuItem(icon: Icons.account_circle, label: 'Profile'),
MenuItem(icon: Icons.logout, label: 'Logout'),
],
)
πΈ Screenshot:
[Header & Footer]
π 4. Custom Colors and Text Styles #
MenuDropdownButton(
tooltip: 'Styled Menu',
icon: Icons.palette,
config: MenuDropdownConfig(
backgroundColor: Colors.blue,
labelTextStyle: TextStyle(color: Colors.yellowAccent),
tooltipBackgroundColor: Colors.black87,
tooltipTextColor: Colors.white,
),
items: [
MenuItem(icon: Icons.visibility, label: 'Preview'),
MenuItem(icon: Icons.save, label: 'Save Draft'),
],
)
πΈ Screenshot:
[Custom Styles]
π 5. Fixed Width and Max Height #
MenuDropdownButton(
tooltip: 'Sized Menu',
icon: Icons.aspect_ratio,
config: MenuDropdownConfig(
width: 200,
maxHeight: 150,
),
items: List.generate(
10,
(i) => MenuItem(icon: Icons.star, label: 'Item ${i + 1}'),
),
)
πΈ Screenshot:
[Fixed Size Menu]
π 6. Divider and Custom Widgets #
MenuDropdownButton(
tooltip: 'Custom Items',
icon: Icons.widgets,
items: [
MenuItem(icon: Icons.settings, label: 'Settings'),
MenuItem(isDivider: true),
MenuItem(
customWidget: Padding(
padding: EdgeInsets.all(12),
child: Row(
children: [
CircleAvatar(radius: 12, backgroundColor: Colors.orange),
SizedBox(width: 10),
Text('Custom User Widget', style: TextStyle(color: Colors.white)),
],
),
),
),
],
)
πΈ Screenshot:
[Dividers and Custom]
π 7. Custom Icon Color & Size for the Root Button #
MenuDropdownButton(
icon: Icons.more_vert,
tooltip: "Menu",
iconColor: Colors.red,
iconSize: 30,
items: [
MenuItem(icon: Icons.settings, label: 'Settings'),
MenuItem(icon: Icons.logout, label: 'Logout'),
],
)
πΈ Screenshot:
[Custom Icon and Size]
π 8. Custom Header & Footer Styles #
MenuDropdownButton(
icon: Icons.menu,
tooltip: "Menu",
header: Text('Menu Header'),
footer: Text('Footer Note'),
config: MenuDropdownConfig(
headerTextStyle: TextStyle(
color: Colors.blue,
fontSize: 16,
fontWeight: FontWeight.bold,
),
footerTextStyle: TextStyle(
color: Colors.green,
fontSize: 12,
fontStyle: FontStyle.italic,
),
),
items: [
MenuItem(icon: Icons.home, label: 'Home'),
MenuItem(icon: Icons.person, label: 'Profile'),
],
)
πΈ Screenshot:
[Header/Footer Styles]
π 9. Custom Tooltip Colors #
MenuDropdownButton(
icon: Icons.info,
tooltip: "Info Tooltip",
tooltipTextColor: Colors.black,
tooltipBackgroundColor: Colors.yellow,
items: [
MenuItem(icon: Icons.help, label: 'Help'),
],
)
πΈ Screenshot:
[Custom Tooltip]
π 10. Label and Icon Colors for Items #
MenuDropdownButton(
icon: Icons.more_horiz,
tooltip: "Options",
items: [
MenuItem(icon: Icons.edit, label: 'Edit'),
MenuItem(icon: Icons.delete, label: 'Delete'),
],
config: MenuDropdownConfig(
backgroundColor: Colors.grey[850]!,
itemIconColor: Colors.amber, // icon color
labelTextStyle: TextStyle(color: Colors.cyan, fontSize: 16), // text style
iconSize: 22,
),
)
πΈ Screenshot:
[Label and Icon Colors for Items]
π 11. Root Text Instead of Icon #
MenuDropdownButton(
tooltip: 'Open Menu',
label: 'Menu',
labelTextStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
items: [
MenuItem(icon: Icons.settings, label: 'Settings'),
MenuItem(icon: Icons.logout, label: 'Logout'),
],
)
πΈ Screenshot:
[Root Text]
π 12. Root Icon + Text Combination #
MenuDropdownButton(
tooltip: 'Open Panel',
icon: Icons.menu,
rootText: 'Dashboard',
rootTextStyle: TextStyle(
fontSize: 15,
color: Colors.deepPurple,
),
items: [
MenuItem(icon: Icons.dashboard, label: 'Overview'),
MenuItem(icon: Icons.analytics, label: 'Reports'),
],
)
πΈ Screenshot:
[Root Icon + Text Combination]
π 13. Invisible Trigger (Secret Function Example) #
MenuDropdownButton(
tooltip: 'Hidden Dev Options',
items: [
MenuItem(icon: Icons.bug_report, label: 'Debug Mode'),
MenuItem(icon: Icons.lock, label: 'Security Console'),
],
)
πΈ Screenshots:
[Invisible Trigger1] [Invisible Trigger]
π 14. Dropdown Size Customization & Auto-Resizing #
The flex_menu_button widget supports both automatic content-based sizing and manual width control.
π Visual Comparison #
| Icon Only (Auto) | Icon Only (Fixed Width) | Icon + Text (Auto) |
|---|---|---|
| [icon_auto] | [icon_fixed] | [icon_text_auto] |
β Example 1 β Icons Only (Auto-Sized) #
MenuDropdownButton(
icon: Icons.more_vert,
tooltip: 'Options',
config: MenuDropdownConfig(),
items: [
MenuItem(icon: Icons.copy, label: ''),
MenuItem(icon: Icons.share, label: ''),
MenuItem(icon: Icons.delete, label: ''),
],
)
πΈ Screenshot: [Icons Only (Auto-Sized)] #
β Example 2 β Icons Only (Fixed Width) #
MenuDropdownButton(
icon: Icons.more_vert,
tooltip: 'Options',
config: MenuDropdownConfig(
width: 180,
),
items: [
MenuItem(icon: Icons.copy, label: ''),
MenuItem(icon: Icons.share, label: ''),
MenuItem(icon: Icons.delete, label: ''),
],
)
πΈ Screenshot: [Icons Only (Fixed Width)] #
β Example 3 β Icons + Text (Auto-Sized) #
MenuDropdownButton(
icon: Icons.more_vert,
tooltip: 'Options',
config: MenuDropdownConfig(),
items: [
MenuItem(icon: Icons.copy, label: 'Copy'),
MenuItem(icon: Icons.share, label: 'Share'),
MenuItem(icon: Icons.delete, label: 'Delete'),
],
)
πΈ Screenshot: [Icons + Text] #
π Note:
If you don't specify a width in MenuDropdownConfig, the dropdown will scale based on the largest element (icon, label, or trailing widget). You can override this with a fixed width value if layout consistency is preferred.