Jaime Blasco
Committed by GitHub

Merge pull request #18 from troyanskiy/open-duration

Open duration
@@ -49,6 +49,7 @@ Also it supports `WillPopScope` to prevent closing the dialog @@ -49,6 +49,7 @@ Also it supports `WillPopScope` to prevent closing the dialog
49 |bool enableDrag = true| The `enableDrag` parameter specifies whether the bottom sheet can be dragged up and down and dismissed by swiping downwards. | 49 |bool enableDrag = true| The `enableDrag` parameter specifies whether the bottom sheet can be dragged up and down and dismissed by swiping downwards. |
50 |AnimationController secondAnimation| The `secondAnimation` parameter allows you to provide an animation controller that will be used to animate push/pop of the modal route. Using this param is advised against and will be probably removed in future versions | 50 |AnimationController secondAnimation| The `secondAnimation` parameter allows you to provide an animation controller that will be used to animate push/pop of the modal route. Using this param is advised against and will be probably removed in future versions |
51 |bool bounce = false| The `bounce` parameter specifies if the bottom sheet can go beyond the top boundary while dragging | 51 |bool bounce = false| The `bounce` parameter specifies if the bottom sheet can go beyond the top boundary while dragging |
  52 +|Duration duration = const Duration(milliseconds: 400)| The `duration` of modal opening |
52 53
53 54
54 #### Material params 55 #### Material params
@@ -81,6 +81,7 @@ Future<T> showAvatarModalBottomSheet<T>({ @@ -81,6 +81,7 @@ Future<T> showAvatarModalBottomSheet<T>({
81 bool useRootNavigator = false, 81 bool useRootNavigator = false,
82 bool isDismissible = true, 82 bool isDismissible = true,
83 bool enableDrag = true, 83 bool enableDrag = true,
  84 + Duration duration,
84 }) async { 85 }) async {
85 assert(context != null); 86 assert(context != null);
86 assert(builder != null); 87 assert(builder != null);
@@ -104,6 +105,7 @@ Future<T> showAvatarModalBottomSheet<T>({ @@ -104,6 +105,7 @@ Future<T> showAvatarModalBottomSheet<T>({
104 isDismissible: isDismissible, 105 isDismissible: isDismissible,
105 modalBarrierColor: barrierColor, 106 modalBarrierColor: barrierColor,
106 enableDrag: enableDrag, 107 enableDrag: enableDrag,
  108 + duration: duration,
107 )); 109 ));
108 return result; 110 return result;
109 } 111 }
@@ -7,42 +7,42 @@ packages: @@ -7,42 +7,42 @@ packages:
7 name: archive 7 name: archive
8 url: "https://pub.dartlang.org" 8 url: "https://pub.dartlang.org"
9 source: hosted 9 source: hosted
10 - version: "2.0.11" 10 + version: "2.0.13"
11 args: 11 args:
12 dependency: transitive 12 dependency: transitive
13 description: 13 description:
14 name: args 14 name: args
15 url: "https://pub.dartlang.org" 15 url: "https://pub.dartlang.org"
16 source: hosted 16 source: hosted
17 - version: "1.5.2" 17 + version: "1.6.0"
18 async: 18 async:
19 dependency: transitive 19 dependency: transitive
20 description: 20 description:
21 name: async 21 name: async
22 url: "https://pub.dartlang.org" 22 url: "https://pub.dartlang.org"
23 source: hosted 23 source: hosted
24 - version: "2.4.0" 24 + version: "2.4.1"
25 boolean_selector: 25 boolean_selector:
26 dependency: transitive 26 dependency: transitive
27 description: 27 description:
28 name: boolean_selector 28 name: boolean_selector
29 url: "https://pub.dartlang.org" 29 url: "https://pub.dartlang.org"
30 source: hosted 30 source: hosted
31 - version: "1.0.5" 31 + version: "2.0.0"
32 charcode: 32 charcode:
33 dependency: transitive 33 dependency: transitive
34 description: 34 description:
35 name: charcode 35 name: charcode
36 url: "https://pub.dartlang.org" 36 url: "https://pub.dartlang.org"
37 source: hosted 37 source: hosted
38 - version: "1.1.2" 38 + version: "1.1.3"
39 collection: 39 collection:
40 dependency: transitive 40 dependency: transitive
41 description: 41 description:
42 name: collection 42 name: collection
43 url: "https://pub.dartlang.org" 43 url: "https://pub.dartlang.org"
44 source: hosted 44 source: hosted
45 - version: "1.14.11" 45 + version: "1.14.12"
46 convert: 46 convert:
47 dependency: transitive 47 dependency: transitive
48 description: 48 description:
@@ -56,7 +56,7 @@ packages: @@ -56,7 +56,7 @@ packages:
56 name: crypto 56 name: crypto
57 url: "https://pub.dartlang.org" 57 url: "https://pub.dartlang.org"
58 source: hosted 58 source: hosted
59 - version: "2.1.3" 59 + version: "2.1.4"
60 cupertino_icons: 60 cupertino_icons:
61 dependency: "direct main" 61 dependency: "direct main"
62 description: 62 description:
@@ -85,7 +85,7 @@ packages: @@ -85,7 +85,7 @@ packages:
85 name: image 85 name: image
86 url: "https://pub.dartlang.org" 86 url: "https://pub.dartlang.org"
87 source: hosted 87 source: hosted
88 - version: "2.1.4" 88 + version: "2.1.12"
89 matcher: 89 matcher:
90 dependency: transitive 90 dependency: transitive
91 description: 91 description:
@@ -106,7 +106,7 @@ packages: @@ -106,7 +106,7 @@ packages:
106 path: ".." 106 path: ".."
107 relative: true 107 relative: true
108 source: path 108 source: path
109 - version: "0.1.4" 109 + version: "0.1.5"
110 path: 110 path:
111 dependency: transitive 111 dependency: transitive
112 description: 112 description:
@@ -114,13 +114,6 @@ packages: @@ -114,13 +114,6 @@ packages:
114 url: "https://pub.dartlang.org" 114 url: "https://pub.dartlang.org"
115 source: hosted 115 source: hosted
116 version: "1.6.4" 116 version: "1.6.4"
117 - pedantic:  
118 - dependency: transitive  
119 - description:  
120 - name: pedantic  
121 - url: "https://pub.dartlang.org"  
122 - source: hosted  
123 - version: "1.8.0+1"  
124 petitparser: 117 petitparser:
125 dependency: transitive 118 dependency: transitive
126 description: 119 description:
@@ -141,7 +134,7 @@ packages: @@ -141,7 +134,7 @@ packages:
141 name: quiver 134 name: quiver
142 url: "https://pub.dartlang.org" 135 url: "https://pub.dartlang.org"
143 source: hosted 136 source: hosted
144 - version: "2.0.5" 137 + version: "2.1.3"
145 sky_engine: 138 sky_engine:
146 dependency: transitive 139 dependency: transitive
147 description: flutter 140 description: flutter
@@ -153,7 +146,7 @@ packages: @@ -153,7 +146,7 @@ packages:
153 name: source_span 146 name: source_span
154 url: "https://pub.dartlang.org" 147 url: "https://pub.dartlang.org"
155 source: hosted 148 source: hosted
156 - version: "1.5.5" 149 + version: "1.7.0"
157 stack_trace: 150 stack_trace:
158 dependency: transitive 151 dependency: transitive
159 description: 152 description:
@@ -188,7 +181,7 @@ packages: @@ -188,7 +181,7 @@ packages:
188 name: test_api 181 name: test_api
189 url: "https://pub.dartlang.org" 182 url: "https://pub.dartlang.org"
190 source: hosted 183 source: hosted
191 - version: "0.2.11" 184 + version: "0.2.15"
192 typed_data: 185 typed_data:
193 dependency: transitive 186 dependency: transitive
194 description: 187 description:
@@ -237,7 +230,7 @@ packages: @@ -237,7 +230,7 @@ packages:
237 name: xml 230 name: xml
238 url: "https://pub.dartlang.org" 231 url: "https://pub.dartlang.org"
239 source: hosted 232 source: hosted
240 - version: "3.5.0" 233 + version: "3.6.1"
241 sdks: 234 sdks:
242 dart: ">=2.7.0 <3.0.0" 235 dart: ">=2.7.0 <3.0.0"
243 flutter: ">=1.12.8 <2.0.0" 236 flutter: ">=1.12.8 <2.0.0"
@@ -60,7 +60,7 @@ class ModalBottomSheet extends StatefulWidget { @@ -60,7 +60,7 @@ class ModalBottomSheet extends StatefulWidget {
60 final AnimationController animationController; 60 final AnimationController animationController;
61 61
62 /// The curve used by the animation showing and dismissing the bottom sheet. 62 /// The curve used by the animation showing and dismissing the bottom sheet.
63 - /// 63 + ///
64 /// If no curve is provided it falls back to `Curves.easeOutSine`. 64 /// If no curve is provided it falls back to `Curves.easeOutSine`.
65 final Curve animationCurve; 65 final Curve animationCurve;
66 66
@@ -108,9 +108,12 @@ class ModalBottomSheet extends StatefulWidget { @@ -108,9 +108,12 @@ class ModalBottomSheet extends StatefulWidget {
108 /// This API available as a convenience for a Material compliant bottom sheet 108 /// This API available as a convenience for a Material compliant bottom sheet
109 /// animation. If alternative animation durations are required, a different 109 /// animation. If alternative animation durations are required, a different
110 /// animation controller could be provided. 110 /// animation controller could be provided.
111 - static AnimationController createAnimationController(TickerProvider vsync) { 111 + static AnimationController createAnimationController(
  112 + TickerProvider vsync, {
  113 + Duration duration,
  114 + }) {
112 return AnimationController( 115 return AnimationController(
113 - duration: _bottomSheetDuration, 116 + duration: duration ?? _bottomSheetDuration,
114 debugLabel: 'BottomSheet', 117 debugLabel: 'BottomSheet',
115 vsync: vsync, 118 vsync: vsync,
116 ); 119 );
@@ -120,6 +120,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -120,6 +120,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
120 @required this.expanded, 120 @required this.expanded,
121 this.bounce = false, 121 this.bounce = false,
122 this.animationCurve, 122 this.animationCurve,
  123 + this.duration,
123 RouteSettings settings, 124 RouteSettings settings,
124 }) : assert(expanded != null), 125 }) : assert(expanded != null),
125 assert(isDismissible != null), 126 assert(isDismissible != null),
@@ -135,11 +136,13 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -135,11 +136,13 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
135 final bool enableDrag; 136 final bool enableDrag;
136 final ScrollController scrollController; 137 final ScrollController scrollController;
137 138
  139 + final Duration duration;
  140 +
138 final AnimationController secondAnimationController; 141 final AnimationController secondAnimationController;
139 final Curve animationCurve; 142 final Curve animationCurve;
140 143
141 @override 144 @override
142 - Duration get transitionDuration => _bottomSheetDuration; 145 + Duration get transitionDuration => duration ?? _bottomSheetDuration;
143 146
144 @override 147 @override
145 bool get barrierDismissible => isDismissible; 148 bool get barrierDismissible => isDismissible;
@@ -155,8 +158,10 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -155,8 +158,10 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
155 @override 158 @override
156 AnimationController createAnimationController() { 159 AnimationController createAnimationController() {
157 assert(_animationController == null); 160 assert(_animationController == null);
158 - _animationController =  
159 - ModalBottomSheet.createAnimationController(navigator.overlay); 161 + _animationController = ModalBottomSheet.createAnimationController(
  162 + navigator.overlay,
  163 + duration: duration,
  164 + );
160 return _animationController; 165 return _animationController;
161 } 166 }
162 167
@@ -218,6 +223,7 @@ Future<T> showCustomModalBottomSheet<T>({ @@ -218,6 +223,7 @@ Future<T> showCustomModalBottomSheet<T>({
218 bool isDismissible = true, 223 bool isDismissible = true,
219 bool enableDrag = true, 224 bool enableDrag = true,
220 ScrollController scrollController, 225 ScrollController scrollController,
  226 + Duration duration,
221 }) async { 227 }) async {
222 assert(context != null); 228 assert(context != null);
223 assert(builder != null); 229 assert(builder != null);
@@ -240,6 +246,7 @@ Future<T> showCustomModalBottomSheet<T>({ @@ -240,6 +246,7 @@ Future<T> showCustomModalBottomSheet<T>({
240 modalBarrierColor: barrierColor, 246 modalBarrierColor: barrierColor,
241 enableDrag: enableDrag, 247 enableDrag: enableDrag,
242 animationCurve: animationCurve, 248 animationCurve: animationCurve,
  249 + duration: duration,
243 )); 250 ));
244 return result; 251 return result;
245 } 252 }
  1 +import 'dart:async';
  2 +
1 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
2 import 'package:flutter/services.dart'; 4 import 'package:flutter/services.dart';
3 -import 'dart:async';  
4 5
5 import '../../modal_bottom_sheet.dart'; 6 import '../../modal_bottom_sheet.dart';
6 import '../bottom_sheet_route.dart'; 7 import '../bottom_sheet_route.dart';
@@ -9,6 +10,7 @@ class BarBottomSheet extends StatelessWidget { @@ -9,6 +10,7 @@ class BarBottomSheet extends StatelessWidget {
9 final Widget child; 10 final Widget child;
10 11
11 const BarBottomSheet({Key key, this.child}) : super(key: key); 12 const BarBottomSheet({Key key, this.child}) : super(key: key);
  13 +
12 @override 14 @override
13 Widget build(BuildContext context) { 15 Widget build(BuildContext context) {
14 return AnnotatedRegion<SystemUiOverlayStyle>( 16 return AnnotatedRegion<SystemUiOverlayStyle>(
@@ -70,6 +72,7 @@ Future<T> showBarModalBottomSheet<T>({ @@ -70,6 +72,7 @@ Future<T> showBarModalBottomSheet<T>({
70 bool useRootNavigator = false, 72 bool useRootNavigator = false,
71 bool isDismissible = true, 73 bool isDismissible = true,
72 bool enableDrag = true, 74 bool enableDrag = true,
  75 + Duration duration,
73 }) async { 76 }) async {
74 assert(context != null); 77 assert(context != null);
75 assert(builder != null); 78 assert(builder != null);
@@ -93,6 +96,7 @@ Future<T> showBarModalBottomSheet<T>({ @@ -93,6 +96,7 @@ Future<T> showBarModalBottomSheet<T>({
93 modalBarrierColor: barrierColor, 96 modalBarrierColor: barrierColor,
94 enableDrag: enableDrag, 97 enableDrag: enableDrag,
95 animationCurve: animationCurve, 98 animationCurve: animationCurve,
  99 + duration: duration,
96 )); 100 ));
97 return result; 101 return result;
98 } 102 }
@@ -78,6 +78,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ @@ -78,6 +78,7 @@ Future<T> showCupertinoModalBottomSheet<T>({
78 bool bounce = true, 78 bool bounce = true,
79 bool isDismissible, 79 bool isDismissible,
80 bool enableDrag = true, 80 bool enableDrag = true,
  81 + Duration duration,
81 }) async { 82 }) async {
82 assert(context != null); 83 assert(context != null);
83 assert(builder != null); 84 assert(builder != null);
@@ -111,6 +112,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ @@ -111,6 +112,7 @@ Future<T> showCupertinoModalBottomSheet<T>({
111 enableDrag: enableDrag, 112 enableDrag: enableDrag,
112 animationCurve: animationCurve, 113 animationCurve: animationCurve,
113 previousRouteAnimationCurve: previousRouteAnimationCurve, 114 previousRouteAnimationCurve: previousRouteAnimationCurve,
  115 + duration: duration,
114 )); 116 ));
115 return result; 117 return result;
116 } 118 }
@@ -132,6 +134,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { @@ -132,6 +134,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
132 bool isDismissible = true, 134 bool isDismissible = true,
133 bool enableDrag = true, 135 bool enableDrag = true,
134 @required bool expanded, 136 @required bool expanded,
  137 + Duration duration,
135 RouteSettings settings, 138 RouteSettings settings,
136 this.previousRouteAnimationCurve, 139 this.previousRouteAnimationCurve,
137 }) : assert(expanded != null), 140 }) : assert(expanded != null),
@@ -149,6 +152,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { @@ -149,6 +152,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
149 expanded: expanded, 152 expanded: expanded,
150 settings: settings, 153 settings: settings,
151 animationCurve: animationCurve, 154 animationCurve: animationCurve,
  155 + duration: duration,
152 ); 156 );
153 157
154 @override 158 @override
@@ -286,6 +290,7 @@ class CupertinoScaffold extends StatefulWidget { @@ -286,6 +290,7 @@ class CupertinoScaffold extends StatefulWidget {
286 bool bounce = true, 290 bool bounce = true,
287 bool isDismissible, 291 bool isDismissible,
288 bool enableDrag = true, 292 bool enableDrag = true,
  293 + Duration duration,
289 }) async { 294 }) async {
290 assert(context != null); 295 assert(context != null);
291 assert(builder != null); 296 assert(builder != null);
@@ -315,6 +320,7 @@ class CupertinoScaffold extends StatefulWidget { @@ -315,6 +320,7 @@ class CupertinoScaffold extends StatefulWidget {
315 enableDrag: enableDrag, 320 enableDrag: enableDrag,
316 animationCurve: animationCurve, 321 animationCurve: animationCurve,
317 previousRouteAnimationCurve: previousRouteAnimationCurve, 322 previousRouteAnimationCurve: previousRouteAnimationCurve,
  323 + duration: duration,
318 )); 324 ));
319 return result; 325 return result;
320 } 326 }
@@ -18,6 +18,7 @@ Future<T> showMaterialModalBottomSheet<T>({ @@ -18,6 +18,7 @@ Future<T> showMaterialModalBottomSheet<T>({
18 bool useRootNavigator = false, 18 bool useRootNavigator = false,
19 bool isDismissible = true, 19 bool isDismissible = true,
20 bool enableDrag = true, 20 bool enableDrag = true,
  21 + Duration duration,
21 }) async { 22 }) async {
22 assert(context != null); 23 assert(context != null);
23 assert(builder != null); 24 assert(builder != null);
@@ -46,6 +47,7 @@ Future<T> showMaterialModalBottomSheet<T>({ @@ -46,6 +47,7 @@ Future<T> showMaterialModalBottomSheet<T>({
46 modalBarrierColor: barrierColor, 47 modalBarrierColor: barrierColor,
47 enableDrag: enableDrag, 48 enableDrag: enableDrag,
48 animationCurve: animationCurve, 49 animationCurve: animationCurve,
  50 + duration: duration,
49 )); 51 ));
50 return result; 52 return result;
51 } 53 }
@@ -7,42 +7,42 @@ packages: @@ -7,42 +7,42 @@ packages:
7 name: archive 7 name: archive
8 url: "https://pub.dartlang.org" 8 url: "https://pub.dartlang.org"
9 source: hosted 9 source: hosted
10 - version: "2.0.11" 10 + version: "2.0.13"
11 args: 11 args:
12 dependency: transitive 12 dependency: transitive
13 description: 13 description:
14 name: args 14 name: args
15 url: "https://pub.dartlang.org" 15 url: "https://pub.dartlang.org"
16 source: hosted 16 source: hosted
17 - version: "1.5.2" 17 + version: "1.6.0"
18 async: 18 async:
19 dependency: transitive 19 dependency: transitive
20 description: 20 description:
21 name: async 21 name: async
22 url: "https://pub.dartlang.org" 22 url: "https://pub.dartlang.org"
23 source: hosted 23 source: hosted
24 - version: "2.4.0" 24 + version: "2.4.1"
25 boolean_selector: 25 boolean_selector:
26 dependency: transitive 26 dependency: transitive
27 description: 27 description:
28 name: boolean_selector 28 name: boolean_selector
29 url: "https://pub.dartlang.org" 29 url: "https://pub.dartlang.org"
30 source: hosted 30 source: hosted
31 - version: "1.0.5" 31 + version: "2.0.0"
32 charcode: 32 charcode:
33 dependency: transitive 33 dependency: transitive
34 description: 34 description:
35 name: charcode 35 name: charcode
36 url: "https://pub.dartlang.org" 36 url: "https://pub.dartlang.org"
37 source: hosted 37 source: hosted
38 - version: "1.1.2" 38 + version: "1.1.3"
39 collection: 39 collection:
40 dependency: transitive 40 dependency: transitive
41 description: 41 description:
42 name: collection 42 name: collection
43 url: "https://pub.dartlang.org" 43 url: "https://pub.dartlang.org"
44 source: hosted 44 source: hosted
45 - version: "1.14.11" 45 + version: "1.14.12"
46 convert: 46 convert:
47 dependency: transitive 47 dependency: transitive
48 description: 48 description:
@@ -56,7 +56,7 @@ packages: @@ -56,7 +56,7 @@ packages:
56 name: crypto 56 name: crypto
57 url: "https://pub.dartlang.org" 57 url: "https://pub.dartlang.org"
58 source: hosted 58 source: hosted
59 - version: "2.1.3" 59 + version: "2.1.4"
60 flutter: 60 flutter:
61 dependency: "direct main" 61 dependency: "direct main"
62 description: flutter 62 description: flutter
@@ -73,7 +73,7 @@ packages: @@ -73,7 +73,7 @@ packages:
73 name: image 73 name: image
74 url: "https://pub.dartlang.org" 74 url: "https://pub.dartlang.org"
75 source: hosted 75 source: hosted
76 - version: "2.1.4" 76 + version: "2.1.12"
77 matcher: 77 matcher:
78 dependency: transitive 78 dependency: transitive
79 description: 79 description:
@@ -115,7 +115,7 @@ packages: @@ -115,7 +115,7 @@ packages:
115 name: quiver 115 name: quiver
116 url: "https://pub.dartlang.org" 116 url: "https://pub.dartlang.org"
117 source: hosted 117 source: hosted
118 - version: "2.0.5" 118 + version: "2.1.3"
119 sky_engine: 119 sky_engine:
120 dependency: transitive 120 dependency: transitive
121 description: flutter 121 description: flutter
@@ -127,7 +127,7 @@ packages: @@ -127,7 +127,7 @@ packages:
127 name: source_span 127 name: source_span
128 url: "https://pub.dartlang.org" 128 url: "https://pub.dartlang.org"
129 source: hosted 129 source: hosted
130 - version: "1.5.5" 130 + version: "1.7.0"
131 stack_trace: 131 stack_trace:
132 dependency: transitive 132 dependency: transitive
133 description: 133 description:
@@ -162,7 +162,7 @@ packages: @@ -162,7 +162,7 @@ packages:
162 name: test_api 162 name: test_api
163 url: "https://pub.dartlang.org" 163 url: "https://pub.dartlang.org"
164 source: hosted 164 source: hosted
165 - version: "0.2.11" 165 + version: "0.2.15"
166 typed_data: 166 typed_data:
167 dependency: transitive 167 dependency: transitive
168 description: 168 description:
@@ -183,7 +183,7 @@ packages: @@ -183,7 +183,7 @@ packages:
183 name: xml 183 name: xml
184 url: "https://pub.dartlang.org" 184 url: "https://pub.dartlang.org"
185 source: hosted 185 source: hosted
186 - version: "3.5.0" 186 + version: "3.6.1"
187 sdks: 187 sdks:
188 - dart: ">=2.4.0 <3.0.0" 188 + dart: ">=2.6.0 <3.0.0"
189 flutter: ">=1.12.0 <2.0.0" 189 flutter: ">=1.12.0 <2.0.0"