Skip to content

Add onLongPress option to DropdownMenuItem #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/dropdown_button2/lib/src/dropdown_menu_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DropdownItem<T> extends _DropdownMenuItemContainer {
super.intrinsicHeight,
super.alignment,
this.onTap,
this.onLongPress,
this.value,
this.enabled = true,
this.closeOnTap = true,
Expand All @@ -23,6 +24,9 @@ class DropdownItem<T> extends _DropdownMenuItemContainer {
/// Called when the dropdown menu item is tapped.
final VoidCallback? onTap;

/// Called when the dropdown menu item is long pressed.
final VoidCallback? onLongPress;

/// The value to return if the user selects this menu item.
///
/// Eventually returned in a call to [DropdownButton.onChanged].
Expand Down Expand Up @@ -223,6 +227,7 @@ class _DropdownItemButtonState<T> extends State<_DropdownItemButton<T>> {
autofocus: isSelectedItem,
enableFeedback: widget.enableFeedback,
onTap: _handleOnTap,
onLongPress: dropdownItem.onLongPress,
onFocusChange: _handleFocusChange,
borderRadius: menuItemStyle.borderRadius,
overlayColor: menuItemStyle.overlayColor,
Expand Down