bierbaumtim

expose curve of the animation for material

@@ -38,6 +38,7 @@ class ModalBottomSheet extends StatefulWidget { @@ -38,6 +38,7 @@ class ModalBottomSheet extends StatefulWidget {
38 const ModalBottomSheet({ 38 const ModalBottomSheet({
39 Key key, 39 Key key,
40 this.animationController, 40 this.animationController,
  41 + this.animationCurve,
41 this.enableDrag = true, 42 this.enableDrag = true,
42 this.containerBuilder, 43 this.containerBuilder,
43 this.bounce = true, 44 this.bounce = true,
@@ -58,6 +59,11 @@ class ModalBottomSheet extends StatefulWidget { @@ -58,6 +59,11 @@ class ModalBottomSheet extends StatefulWidget {
58 /// is not just a passive observer. 59 /// is not just a passive observer.
59 final AnimationController animationController; 60 final AnimationController animationController;
60 61
  62 + /// The curve used by the animation showing and dismissing the bottom sheet.
  63 + ///
  64 + /// If no curve is provided it falls back to `Curves.easeOutSine`.
  65 + final Curve animationCurve;
  66 +
61 /// Allows the bottom sheet to go beyond the top bound of the content, 67 /// Allows the bottom sheet to go beyond the top bound of the content,
62 /// but then bounce the content back to the edge of 68 /// but then bounce the content back to the edge of
63 /// the top bound. 69 /// the top bound.
@@ -276,7 +282,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -276,7 +282,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
276 Widget build(BuildContext context) { 282 Widget build(BuildContext context) {
277 final bounceAnimation = CurvedAnimation( 283 final bounceAnimation = CurvedAnimation(
278 parent: _bounceDragController, 284 parent: _bounceDragController,
279 - curve: Curves.easeOutSine, 285 + curve: widget.animationCurve ?? Curves.easeOutSine,
280 ); 286 );
281 287
282 var child = widget.builder(context, _scrollController); 288 var child = widget.builder(context, _scrollController);
@@ -17,6 +17,7 @@ class _ModalBottomSheet<T> extends StatefulWidget { @@ -17,6 +17,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
17 this.scrollController, 17 this.scrollController,
18 this.expanded = false, 18 this.expanded = false,
19 this.enableDrag = true, 19 this.enableDrag = true,
  20 + this.animationCurve,
20 }) : assert(expanded != null), 21 }) : assert(expanded != null),
21 assert(enableDrag != null), 22 assert(enableDrag != null),
22 super(key: key); 23 super(key: key);
@@ -26,6 +27,7 @@ class _ModalBottomSheet<T> extends StatefulWidget { @@ -26,6 +27,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
26 final bool bounce; 27 final bool bounce;
27 final bool enableDrag; 28 final bool enableDrag;
28 final AnimationController secondAnimationController; 29 final AnimationController secondAnimationController;
  30 + final Curve animationCurve;
29 final ScrollController scrollController; 31 final ScrollController scrollController;
30 32
31 @override 33 @override
@@ -97,6 +99,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -97,6 +99,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
97 builder: widget.route.builder, 99 builder: widget.route.builder,
98 enableDrag: widget.enableDrag, 100 enableDrag: widget.enableDrag,
99 bounce: widget.bounce, 101 bounce: widget.bounce,
  102 + animationCurve: widget.animationCurve,
100 ), 103 ),
101 ); 104 );
102 }, 105 },
@@ -116,6 +119,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -116,6 +119,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
116 this.enableDrag = true, 119 this.enableDrag = true,
117 @required this.expanded, 120 @required this.expanded,
118 this.bounce = false, 121 this.bounce = false,
  122 + this.animationCurve,
119 RouteSettings settings, 123 RouteSettings settings,
120 }) : assert(expanded != null), 124 }) : assert(expanded != null),
121 assert(isDismissible != null), 125 assert(isDismissible != null),
@@ -132,6 +136,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -132,6 +136,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
132 final ScrollController scrollController; 136 final ScrollController scrollController;
133 137
134 final AnimationController secondAnimationController; 138 final AnimationController secondAnimationController;
  139 + final Curve animationCurve;
135 140
136 @override 141 @override
137 Duration get transitionDuration => _bottomSheetDuration; 142 Duration get transitionDuration => _bottomSheetDuration;
@@ -172,6 +177,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -172,6 +177,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
172 scrollController: scrollController, 177 scrollController: scrollController,
173 bounce: bounce, 178 bounce: bounce,
174 enableDrag: enableDrag, 179 enableDrag: enableDrag,
  180 + animationCurve: animationCurve,
175 ), 181 ),
176 ); 182 );
177 return bottomSheet; 183 return bottomSheet;
@@ -195,8 +201,8 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -195,8 +201,8 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
195 } 201 }
196 202
197 /// Shows a modal material design bottom sheet. 203 /// Shows a modal material design bottom sheet.
198 -Future<T> showCustomModalBottomSheet<T>(  
199 - {@required BuildContext context, 204 +Future<T> showCustomModalBottomSheet<T>({
  205 + @required BuildContext context,
200 @required ScrollWidgetBuilder builder, 206 @required ScrollWidgetBuilder builder,
201 @required WidgetWithChildBuilder containerWidget, 207 @required WidgetWithChildBuilder containerWidget,
202 Color backgroundColor, 208 Color backgroundColor,
@@ -207,10 +213,12 @@ Future<T> showCustomModalBottomSheet<T>( @@ -207,10 +213,12 @@ Future<T> showCustomModalBottomSheet<T>(
207 bool bounce = false, 213 bool bounce = false,
208 bool expand = false, 214 bool expand = false,
209 AnimationController secondAnimation, 215 AnimationController secondAnimation,
  216 + Curve animationCurve,
210 bool useRootNavigator = false, 217 bool useRootNavigator = false,
211 bool isDismissible = true, 218 bool isDismissible = true,
212 bool enableDrag = true, 219 bool enableDrag = true,
213 - ScrollController scrollController}) async { 220 + ScrollController scrollController,
  221 +}) async {
214 assert(context != null); 222 assert(context != null);
215 assert(builder != null); 223 assert(builder != null);
216 assert(containerWidget != null); 224 assert(containerWidget != null);
@@ -231,6 +239,7 @@ Future<T> showCustomModalBottomSheet<T>( @@ -231,6 +239,7 @@ Future<T> showCustomModalBottomSheet<T>(
231 isDismissible: isDismissible, 239 isDismissible: isDismissible,
232 modalBarrierColor: barrierColor, 240 modalBarrierColor: barrierColor,
233 enableDrag: enableDrag, 241 enableDrag: enableDrag,
  242 + animationCurve: animationCurve,
234 )); 243 ));
235 return result; 244 return result;
236 } 245 }
@@ -66,6 +66,7 @@ Future<T> showBarModalBottomSheet<T>({ @@ -66,6 +66,7 @@ Future<T> showBarModalBottomSheet<T>({
66 bool bounce = true, 66 bool bounce = true,
67 bool expand = false, 67 bool expand = false,
68 AnimationController secondAnimation, 68 AnimationController secondAnimation,
  69 + Curve animationCurve,
69 bool useRootNavigator = false, 70 bool useRootNavigator = false,
70 bool isDismissible = true, 71 bool isDismissible = true,
71 bool enableDrag = true, 72 bool enableDrag = true,
@@ -91,6 +92,7 @@ Future<T> showBarModalBottomSheet<T>({ @@ -91,6 +92,7 @@ Future<T> showBarModalBottomSheet<T>({
91 isDismissible: isDismissible, 92 isDismissible: isDismissible,
92 modalBarrierColor: barrierColor, 93 modalBarrierColor: barrierColor,
93 enableDrag: enableDrag, 94 enableDrag: enableDrag,
  95 + animationCurve: animationCurve,
94 )); 96 ));
95 return result; 97 return result;
96 } 98 }
@@ -14,6 +14,7 @@ Future<T> showMaterialModalBottomSheet<T>({ @@ -14,6 +14,7 @@ Future<T> showMaterialModalBottomSheet<T>({
14 bool bounce = false, 14 bool bounce = false,
15 bool expand = false, 15 bool expand = false,
16 AnimationController secondAnimation, 16 AnimationController secondAnimation,
  17 + Curve animationCurve,
17 bool useRootNavigator = false, 18 bool useRootNavigator = false,
18 bool isDismissible = true, 19 bool isDismissible = true,
19 bool enableDrag = true, 20 bool enableDrag = true,
@@ -44,6 +45,7 @@ Future<T> showMaterialModalBottomSheet<T>({ @@ -44,6 +45,7 @@ Future<T> showMaterialModalBottomSheet<T>({
44 isDismissible: isDismissible, 45 isDismissible: isDismissible,
45 modalBarrierColor: barrierColor, 46 modalBarrierColor: barrierColor,
46 enableDrag: enableDrag, 47 enableDrag: enableDrag,
  48 + animationCurve: animationCurve,
47 )); 49 ));
48 return result; 50 return result;
49 } 51 }