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 onAttached callback #200

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ There are several options that allow for more control:
| `onPanelSlide` | If non-null, this callback is called as the panel slides around with the current position of the panel. The position is a double between 0.0 and 1.0 where 0.0 is fully collapsed and 1.0 is fully open. |
| `onPanelOpened` | If non-null, this callback is called when the panel is fully opened. |
| `onPanelClosed` | If non-null, this callback is called when the panel is fully collapsed. |
| `onAttached` | If non-null, this callback is called when the panel controller is attached to a SlidingUpPanel. |
| `parallaxEnabled` | If non-null and true, the SlidingUpPanel exhibits a parallax effect as the panel slides up. Essentially, the body slides up as the panel slides up. |
| `parallaxOffset` | Allows for specifying the extent of the parallax effect in terms of the percentage the panel has slid up/down. Recommended values are within 0.0 and 1.0 where 0.0 is no parallax and 1.0 mimics a one-to-one scrolling effect. Defaults to a 10% parallax. |
| `isDraggable` | Allows toggling of draggability of the SlidingUpPanel. Set this to false to prevent the user from being able to drag the panel up and down. Defaults to true. |
Expand Down
8 changes: 7 additions & 1 deletion lib/src/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ class SlidingUpPanel extends StatefulWidget {
/// is fully collapsed.
final VoidCallback onPanelClosed;

/// If non-null, this callback is called when the panel
/// controller is attached to a SlidingUpPanel
final VoidCallback onAttached;

/// If non-null and true, the SlidingUpPanel exhibits a
/// parallax effect as the panel slides up. Essentially,
/// the body slides up as the panel slides up.
Expand Down Expand Up @@ -199,7 +203,8 @@ class SlidingUpPanel extends StatefulWidget {
this.slideDirection = SlideDirection.UP,
this.defaultPanelState = PanelState.CLOSED,
this.header,
this.footer
this.footer,
this.onAttached
}) : assert(panel != null || panelBuilder != null),
assert(0 <= backdropOpacity && backdropOpacity <= 1.0),
assert (snapPoint == null || 0 < snapPoint && snapPoint < 1.0),
Expand Down Expand Up @@ -244,6 +249,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
});

widget.controller?._addState(this);
if(widget.onAttached != null) widget.onAttached();
}

@override
Expand Down