Skip to content

Commit

Permalink
Fixes LanarsInc#63: add onTap behaviour when dismissType in onSwipe
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRomeroMediabyte committed Oct 13, 2024
1 parent eed8efe commit d8a5f3e
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions lib/top_snack_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d8a5f3e

Please sign in to comment.