@@ -29,7 +29,7 @@ class GFBottomSheet extends StatefulWidget {
2929 // from the app and don't depend of user's interaction.
3030 // can hide and show methods plus have isOpened variable
3131 // to check widget visibility on a screen
32- SolidController controller;
32+ GFBottomSheeetController controller;
3333
3434 final int smoothness;
3535
@@ -47,7 +47,7 @@ class GFBottomSheet extends StatefulWidget {
4747 assert (minHeight >= 0.0 ),
4848 super (key: key) {
4949 if (controller == null ) {
50- this .controller = SolidController ();
50+ this .controller = GFBottomSheeetController ();
5151 }
5252 this .controller.height = this .minHeight;
5353 this .controller.Smoothness = smoothness;
@@ -88,17 +88,10 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
8888 }
8989
9090 Function _controllerListener;
91- AnimationController _controller;
9291
9392 @override
9493 void initState () {
9594 super .initState ();
96- // _controller = AnimationController(
97- // vsync: this,
98- // lowerBound: 0.0,
99- // upperBound: 1.0,
100- // );
101- // _controller.addStatusListener(_controllerListener);
10295 widget.controller.value = showBottomSheet;
10396 _controllerListener = () {
10497 widget.controller.value ? _show () : _hide ();
@@ -131,24 +124,22 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
131124 child: widget.stickyHeader,
132125 ),
133126 ),
134- StreamBuilder <double >(
135- stream: widget.controller.heightStream,
136- initialData: widget.controller.height,
137- builder: (_, snapshot) =>
138- AnimatedContainer (
139- curve: Curves .easeOut,
140- duration:
141- Duration (milliseconds: widget.controller.Smoothness ),
142- height: snapshot.data,
143- child: GestureDetector (
144- onVerticalDragUpdate: _onVerticalDragUpdate,
145- onVerticalDragEnd: _onVerticalDragEnd,
146- onTap: _onTap,
147- child: widget.contentBody,
148- ),
127+ AnimatedBuilder (
128+ animation: widget.controller,
129+ builder: (_, Widget child) =>
130+ AnimatedContainer (
131+ curve: Curves .easeOut,
132+ duration: Duration (milliseconds: widget.controller.Smoothness ),
133+ height: widget.controller.height,
134+ child: GestureDetector (
135+ onVerticalDragUpdate: _onVerticalDragUpdate,
136+ onVerticalDragEnd: _onVerticalDragEnd,
137+ onTap: _onTap,
138+ child: widget.contentBody,
149139 ),
140+ ),
150141 ),
151- widget.controller.height == widget.maxHeight
142+ widget.controller.height == 0
152143 ? widget.stickyFooter
153144 : Container ()
154145 ],
@@ -158,12 +149,10 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
158149
159150 void _hide () {
160151 widget.controller.height = widget.minHeight;
161- print ('hhhhhhhhhhhh ${ widget .controller .height == widget .maxHeight }' );
162152 }
163153
164154 void _show () {
165155 widget.controller.height = widget.maxHeight;
166- print ('sssssssss ${ widget .controller .height == widget .maxHeight }' );
167156 }
168157
169158 @override
@@ -181,27 +170,27 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
181170 }
182171}
183172
184- class SolidController extends ValueNotifier <bool > {
185- SolidBloc _bloc = SolidBloc ();
173+ class GFBottomSheeetController extends ValueNotifier <bool > {
174+ // SolidBloc _bloc = SolidBloc();
186175
187176 // This is the current height of the bottomSheet's body
188177 double _height;
189178
190179 // This is the current smoothness of the bottomSheet
191180 int Smoothness ;
192181
193- SolidController () : super (false );
182+ GFBottomSheeetController () : super (false );
194183
195- // Returns the value of the height as stream
196- Stream <double > get heightStream => _bloc.height;
197-
198- // Returns the value of the visibility as stream
199- Stream <bool > get isOpenStream => _bloc.isOpen;
184+ // // Returns the value of the height as stream
185+ // Stream<double> get heightStream => _bloc.height;
186+ //
187+ // // Returns the value of the visibility as stream
188+ // Stream<bool> get isOpenStream => _bloc.isOpen;
200189
201190 // This method sets the value of the height using streams
202191 set height (double value) {
203192 _height = value;
204- _bloc.dispatch (value);
193+ // _bloc.dispatch(value);
205194 }
206195
207196 // Returns the value of the height
@@ -218,31 +207,31 @@ class SolidController extends ValueNotifier<bool> {
218207
219208 @override
220209 void dispose () {
221- _bloc.dispose ();
210+ // _bloc.dispose();
222211 super .dispose ();
223212 }
224213}
225214
226- class SolidBloc {
227- StreamController <double > _heightController =
228- StreamController <double >.broadcast ();
229- Stream <double > get height => _heightController.stream;
230- Sink <double > get _heightSink => _heightController.sink;
231-
232- StreamController <bool > _visibilityController =
233- StreamController <bool >.broadcast ();
234- Stream <bool > get isOpen => _visibilityController.stream;
235- Sink <bool > get _visibilitySink => _visibilityController.sink;
236-
237- // Adds new values to streams
238- void dispatch (double value) {
239- _heightSink.add (value);
240- _visibilitySink.add (value > 0 );
241- }
242-
243- // Closes streams
244- void dispose () {
245- _heightController.close ();
246- _visibilityController.close ();
247- }
248- }
215+ // class SolidBloc {
216+ // StreamController<double> _heightController =
217+ // StreamController<double>.broadcast();
218+ // Stream<double> get height => _heightController.stream;
219+ // Sink<double> get _heightSink => _heightController.sink;
220+ //
221+ // StreamController<bool> _visibilityController =
222+ // StreamController<bool>.broadcast();
223+ // Stream<bool> get isOpen => _visibilityController.stream;
224+ // Sink<bool> get _visibilitySink => _visibilityController.sink;
225+ //
226+ // // Adds new values to streams
227+ // void dispatch(double value) {
228+ // _heightSink.add(value);
229+ // _visibilitySink.add(value > 0);
230+ // }
231+ //
232+ // // Closes streams
233+ // void dispose() {
234+ // _heightController.close();
235+ // _visibilityController.close();
236+ // }
237+ // }
0 commit comments