From c85f65d18d51a4082ea84f7a204510b13c6f63cd Mon Sep 17 00:00:00 2001 From: sanjidbillah Date: Sun, 26 Dec 2021 17:57:20 +0600 Subject: [PATCH] Add open & closing callback listener --- README.md | 5 ++++- example/lib/main.dart | 5 ++++- lib/src/slidable.dart | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e88b7cc4..f1ff80bc 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,10 @@ Example: Slidable( // Specify a key if the Slidable is dismissible. key: const ValueKey(0), - + // Listen slider open status + onOpen: (bool status) { + // print(status); + }, // The start action pane is the one at the left or the top side. startActionPane: ActionPane( // A motion is a widget used to control how the pane animates. diff --git a/example/lib/main.dart b/example/lib/main.dart index 97415b3b..d490f731 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -18,7 +18,10 @@ class MyApp extends StatelessWidget { Slidable( // Specify a key if the Slidable is dismissible. key: const ValueKey(0), - + // Listen slider open status + onOpen: (bool status) { + // print(status); + }, // The start action pane is the one at the left or the top side. startActionPane: ActionPane( // A motion is a widget used to control how the pane animates. diff --git a/lib/src/slidable.dart b/lib/src/slidable.dart index 889e67a2..c055b24f 100644 --- a/lib/src/slidable.dart +++ b/lib/src/slidable.dart @@ -21,6 +21,7 @@ class Slidable extends StatefulWidget { Key? key, this.groupTag, this.enabled = true, + this.onOpen, this.closeOnScroll = true, this.startActionPane, this.endActionPane, @@ -37,6 +38,9 @@ class Slidable extends StatefulWidget { /// Defaults to true. final bool enabled; + /// Notify when slide open or close + final ValueChanged? onOpen; + /// Specifies to close this [Slidable] after the closest [Scrollable]'s /// position changed. /// @@ -178,6 +182,7 @@ class _SlidableState extends State } void handleActionPanelTypeChanged() { + widget.onOpen?.call(!controller.closing); setState(() { updateMoveAnimation(); });