From d8a5f3e150b68b243cd6460ab488055cd759a7ce Mon Sep 17 00:00:00 2001 From: Darien Romero Date: Sun, 13 Oct 2024 10:05:35 -0500 Subject: [PATCH] Fixes #63: add onTap behaviour when dismissType in onSwipe --- lib/top_snack_bar.dart | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/top_snack_bar.dart b/lib/top_snack_bar.dart index 941ba8e..134cf57 100644 --- a/lib/top_snack_bar.dart +++ b/lib/top_snack_bar.dart @@ -247,21 +247,29 @@ class _TopSnackBarState extends State<_TopSnackBar> with SingleTickerProviderSta case DismissType.onSwipe: var childWidget = widget.child; for (final direction in widget.dismissDirections) { - childWidget = Dismissible( - direction: direction, - key: UniqueKey(), - dismissThresholds: const {DismissDirection.up: 0.2}, - confirmDismiss: (direction) async { + childWidget = TapBounceContainer( + onTap: () { + widget.onTap?.call(); if (!widget.persistent && mounted) { - if (direction == DismissDirection.down) { - await _animationController.reverse(); - } else { - _animationController.reset(); - } + _animationController.reverse(); } - return false; }, - child: childWidget, + child: Dismissible( + direction: direction, + key: UniqueKey(), + dismissThresholds: const {DismissDirection.up: 0.2}, + confirmDismiss: (direction) async { + if (!widget.persistent && mounted) { + if (direction == DismissDirection.down) { + await _animationController.reverse(); + } else { + _animationController.reset(); + } + } + return false; + }, + child: childWidget, + ), ); } return childWidget;