Skip to content

Add support for setting onLongPress handler for MultiSelectContainer #7

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 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MultiSelectContainer<T> extends StatefulWidget {
this.splashColor,
this.highlightColor,
this.controller, this.singleSelectedItem = false,
this.onLongPress,
}) : super(key: key);

/// [MultiSelectCard] List for the multi select container.
Expand Down Expand Up @@ -93,6 +94,9 @@ class MultiSelectContainer<T> extends StatefulWidget {
/// Call when item is selected.
final void Function(List<T> selectedItems, T selectedItem) onChange;

/// Call when item is long-pressed.
final void Function(T item)? onLongPress;

@override
_SimpleMultiSelectContainerState createState() =>
_SimpleMultiSelectContainerState<T>();
Expand Down Expand Up @@ -318,6 +322,14 @@ class _SimpleMultiSelectContainerState<T>
child: InkWell(
splashColor: item.splashColor ?? widget.splashColor,
highlightColor: item.highlightColor ?? widget.highlightColor,
onLongPress: (item.enabled == false)
? null
: () {
var fn = widget.onLongPress;
if (fn != null) {
fn(item.value);
}
},
onTap: item.enabled == false
? null
: () {
Expand Down