How to make a Chip
to support a tap to trigger an action in addition to the onDeleted
?
In my code, adding a gesture handler hides onDeleted
tap triggering:
/// A tappable chip
Widget _tappableChip({
/// The chip label
required String label,
/// Potential badge
int? badge,
/// The function to run when a tap occures
void Function()? onTap,
/// The function to remove the filter
void Function()? onDeleted,
}) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 5, 0),
child: GestureDetector(
onTap: onTap,
child: Chip(
onDeleted: onDeleted,
label: Text(label),
avatar: badge == null ? null : Badge.count(count: badge),
),
),
);
}
2
Answers
You can call both method inside
onDelete
in_tappableChip
here i have done some changes in your tappableChip widget
–
and now you can use tappableChip funcation like this –