From 87b3d1b7fd10808b33cae2e144047bf6db355bd1 Mon Sep 17 00:00:00 2001 From: Sathish Date: Tue, 22 Sep 2020 11:26:37 +0530 Subject: [PATCH] add onAttached callback --- README.md | 1 + lib/src/panel.dart | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 858b20d..27b1d0e 100644 --- a/README.md +++ b/README.md @@ -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. | diff --git a/lib/src/panel.dart b/lib/src/panel.dart index ca397cf..b561098 100644 --- a/lib/src/panel.dart +++ b/lib/src/panel.dart @@ -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. @@ -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), @@ -244,6 +249,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid }); widget.controller?._addState(this); + if(widget.onAttached != null) widget.onAttached(); } @override