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

Fixed onClosed callback #2

Merged
merged 3 commits into from
Jun 8, 2022
Merged
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
1 change: 0 additions & 1 deletion example/.flutter-plugins-dependencies

This file was deleted.

12 changes: 7 additions & 5 deletions lib/src/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum SlideDirection {
DOWN,
}

enum PanelState { OPEN, CLOSED }
enum PanelState { OPEN, CLOSED, HIDDEN }

class SlidingUpPanel extends StatefulWidget {
/// The Widget that slides into view. When the
Expand Down Expand Up @@ -219,12 +219,13 @@ class _SlidingUpPanelState extends State<SlidingUpPanel>
bool _scrollingEnabled = false;
VelocityTracker _vt = new VelocityTracker.withKind(PointerDeviceKind.touch);

bool _isPanelVisible = true;
late bool _isPanelVisible;

@override
void initState() {
super.initState();

_isPanelVisible =
widget.defaultPanelState == PanelState.HIDDEN ? false : true;
_ac = new AnimationController(
vsync: this,
duration: const Duration(milliseconds: 300),
Expand All @@ -238,8 +239,9 @@ class _SlidingUpPanelState extends State<SlidingUpPanel>
if (widget.onPanelOpened != null && _ac.value == 1.0)
widget.onPanelOpened!();

if (widget.onPanelClosed != null && _ac.value == 0.0)
widget.onPanelClosed!();
if (widget.onPanelClosed != null &&
_ac.value == 0.0 &&
!_ac.isAnimating) widget.onPanelClosed!();
});

// prevent the panel content from being scrolled only if the widget is
Expand Down