modules/menu/menu library
A searchable dropdown menu widget.
Menu renders a compact trigger button that, when tapped, opens an
overlay dropdown populated with MenuItems. It supports optional
type-to-search filtering (set MenuConfig.searchable to true),
keyboard navigation (arrow keys, Enter, Escape), and colour history.
Quick Start
Menu(
height: 40,
width: 200,
items: [
MenuItem(label: 'Option A', value: 'a'),
MenuItem(label: 'Option B', value: 'b'),
],
)
Architecture
The menu is split into several collaborating classes:
| Class | Role |
|---|---|
| Menu | Root widget — trigger button & overlay host |
| MenuController | State management & overlay lifecycle |
| MenuItem | Data model + widget builder for each row |
| MenuScope | InheritedWidget providing controller access |
| MenuConfig | Visual / behavioural options for the menu |
| ItemConfig | Visual options for individual items |
Classes
- ItemConfig
- Visual configuration for individual dropdown items.
- Menu
- A dropdown menu widget with optional search, filter, and keyboard support.
- MenuConfig
- Behavioural and visual configuration for a Menu widget.
- MenuController
- Manages the lifecycle, selection, filtering, and overlay visibility of a Menu.
- MenuItem
- A single selectable entry in a Menu dropdown.
- MenuScope
- An InheritedWidget that provides the active MenuController, ItemConfig, and item height to descendant widgets.
- MenuState
- Immutable snapshot of the menu's current state.
Enums
- Aligned
- Horizontal alignment options for menu item text.