Skip to content
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

Add open & closing callback listener #290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions lib/src/slidable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Slidable extends StatefulWidget {
Key? key,
this.groupTag,
this.enabled = true,
this.onOpen,
this.closeOnScroll = true,
this.startActionPane,
this.endActionPane,
Expand All @@ -37,6 +38,9 @@ class Slidable extends StatefulWidget {
/// Defaults to true.
final bool enabled;

/// Notify when slide open or close
final ValueChanged<bool>? onOpen;

/// Specifies to close this [Slidable] after the closest [Scrollable]'s
/// position changed.
///
Expand Down Expand Up @@ -178,6 +182,7 @@ class _SlidableState extends State<Slidable>
}

void handleActionPanelTypeChanged() {
widget.onOpen?.call(!controller.closing);
setState(() {
updateMoveAnimation();
});
Expand Down