Jaime Blasco

Format and fix lint issues.

1 -## [0.0.1] - TODO: Add release date. 1 +## [0.0.1] - Pre Release.
  2 +
  3 +## [0.1.0] - Package Release.
  4 +
2 5
3 -* TODO: Describe initial release.  
1 -<img src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/preview.png"> 1 +<img src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/preview.png?raw=true">
2 2
3 # Flutter Modal Bottom Sheet 3 # Flutter Modal Bottom Sheet
4 4
5 Create awesome and powerful modal bottom sheets 5 Create awesome and powerful modal bottom sheets
6 6
7 -<img align="left" height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/cupertino_shared_view.gif">  
8 -<img align="left" height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/modal_inside_modal.gif">  
9 -<img align="left" height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/material_fit.png">  
10 -<img align="left"height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/bar_modal.png">  
11 -<img height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/avatar_modal.png"> 7 +| Cupertino Modal | Multiple Modals | Material Modal | Bar Modal | Create your own |
  8 +|---|---|---|---|---|
  9 +|<img height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/cupertino_shared_view.gif?raw=true">| <img height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/modal_inside_modal.gif?raw=true">| <img height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/material_fit.png?raw=true">|<img height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/bar_modal.png?raw=true">| <img height="300" src="https://github.com/jamesblasco/modal_bottom_sheet/blob/master/screenshots/avatar_modal.png?raw=true">|
  10 +
12 11
13 12
14 ## Material Modal BottomSheet 13 ## Material Modal BottomSheet
@@ -38,11 +38,13 @@ class MyApp extends StatelessWidget { @@ -38,11 +38,13 @@ class MyApp extends StatelessWidget {
38 middle: Text('Normal Navigation Presentation'), 38 middle: Text('Normal Navigation Presentation'),
39 trailing: GestureDetector( 39 trailing: GestureDetector(
40 child: Icon(Icons.arrow_upward), 40 child: Icon(Icons.arrow_upward),
41 - onTap: () => CupertinoScaffold.showCupertinoModalBottomSheet( 41 + onTap: () => CupertinoScaffold
  42 + .showCupertinoModalBottomSheet(
42 expand: true, 43 expand: true,
43 context: context, 44 context: context,
44 backgroundColor: Colors.transparent, 45 backgroundColor: Colors.transparent,
45 - builder: (context, scrollController) => Stack( 46 + builder: (context, scrollController) =>
  47 + Stack(
46 children: <Widget>[ 48 children: <Widget>[
47 ModalWithScroll( 49 ModalWithScroll(
48 scrollController: scrollController), 50 scrollController: scrollController),
@@ -52,7 +54,8 @@ class MyApp extends StatelessWidget { @@ -52,7 +54,8 @@ class MyApp extends StatelessWidget {
52 right: 40, 54 right: 40,
53 bottom: 20, 55 bottom: 20,
54 child: MaterialButton( 56 child: MaterialButton(
55 - onPressed: () => Navigator.of(context) 57 + onPressed: () => Navigator.of(
  58 + context)
56 .popUntil((route) => 59 .popUntil((route) =>
57 route.settings.name == '/'), 60 route.settings.name == '/'),
58 child: Text('Pop back home'), 61 child: Text('Pop back home'),
@@ -64,7 +67,9 @@ class MyApp extends StatelessWidget { @@ -64,7 +67,9 @@ class MyApp extends StatelessWidget {
64 ), 67 ),
65 child: Center(child: Container()), 68 child: Center(child: Container()),
66 ), 69 ),
67 - ),),), 70 + ),
  71 + ),
  72 + ),
68 settings: settings); 73 settings: settings);
69 }, 74 },
70 debugShowCheckedModeBanner: false, 75 debugShowCheckedModeBanner: false,
@@ -114,8 +119,7 @@ class _MyHomePageState extends State<MyHomePage> { @@ -114,8 +119,7 @@ class _MyHomePageState extends State<MyHomePage> {
114 context: context, 119 context: context,
115 backgroundColor: Colors.transparent, 120 backgroundColor: Colors.transparent,
116 builder: (context, scrollController) => 121 builder: (context, scrollController) =>
117 - ModalFit(  
118 - scrollController: scrollController), 122 + ModalFit(scrollController: scrollController),
119 )), 123 )),
120 ListTile( 124 ListTile(
121 title: Text('Bar Modal'), 125 title: Text('Bar Modal'),
@@ -144,8 +148,7 @@ class _MyHomePageState extends State<MyHomePage> { @@ -144,8 +148,7 @@ class _MyHomePageState extends State<MyHomePage> {
144 context: context, 148 context: context,
145 backgroundColor: Colors.transparent, 149 backgroundColor: Colors.transparent,
146 builder: (context, scrollController) => 150 builder: (context, scrollController) =>
147 - ModalFit(  
148 - scrollController: scrollController), 151 + ModalFit(scrollController: scrollController),
149 )), 152 )),
150 ListTile( 153 ListTile(
151 title: Text('Cupertino Small Modal forzed to expand'), 154 title: Text('Cupertino Small Modal forzed to expand'),
@@ -154,13 +157,11 @@ class _MyHomePageState extends State<MyHomePage> { @@ -154,13 +157,11 @@ class _MyHomePageState extends State<MyHomePage> {
154 context: context, 157 context: context,
155 backgroundColor: Colors.transparent, 158 backgroundColor: Colors.transparent,
156 builder: (context, scrollController) => 159 builder: (context, scrollController) =>
157 - ModalFit(  
158 - scrollController: scrollController), 160 + ModalFit(scrollController: scrollController),
159 )), 161 )),
160 ListTile( 162 ListTile(
161 title: Text('Cupertino Modal inside modal'), 163 title: Text('Cupertino Modal inside modal'),
162 - onTap: () =>  
163 - showCupertinoModalBottomSheet( 164 + onTap: () => showCupertinoModalBottomSheet(
164 expand: true, 165 expand: true,
165 context: context, 166 context: context,
166 backgroundColor: Colors.transparent, 167 backgroundColor: Colors.transparent,
@@ -169,8 +170,7 @@ class _MyHomePageState extends State<MyHomePage> { @@ -169,8 +170,7 @@ class _MyHomePageState extends State<MyHomePage> {
169 scrollController: scrollController), 170 scrollController: scrollController),
170 )), 171 )),
171 ListTile( 172 ListTile(
172 - title:  
173 - Text('Cupertino Navigator + Scroll + WillScope'), 173 + title: Text('Cupertino Navigator + Scroll + WillScope'),
174 onTap: () => showCupertinoModalBottomSheet( 174 onTap: () => showCupertinoModalBottomSheet(
175 expand: true, 175 expand: true,
176 context: context, 176 context: context,
@@ -194,7 +194,6 @@ class _MyHomePageState extends State<MyHomePage> { @@ -194,7 +194,6 @@ class _MyHomePageState extends State<MyHomePage> {
194 ), 194 ),
195 ), 195 ),
196 ), 196 ),
197 -  
198 ), 197 ),
199 ); 198 );
200 } 199 }
@@ -28,7 +28,8 @@ class AvatarBottomSheet extends StatelessWidget { @@ -28,7 +28,8 @@ class AvatarBottomSheet extends StatelessWidget {
28 builder: (context, child) => Transform.translate( 28 builder: (context, child) => Transform.translate(
29 offset: Offset(0, (1 - animation.value) * 100), 29 offset: Offset(0, (1 - animation.value) * 100),
30 child: Opacity( 30 child: Opacity(
31 - child: child, opacity: max(0, animation.value * 2 - 1))), 31 + child: child,
  32 + opacity: max(0, animation.value * 2 - 1))),
32 child: Row( 33 child: Row(
33 children: <Widget>[ 34 children: <Widget>[
34 SizedBox(width: 20), 35 SizedBox(width: 20),
1 -  
2 import 'package:flutter/cupertino.dart'; 1 import 'package:flutter/cupertino.dart';
3 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
4 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; 3 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
@@ -12,7 +11,8 @@ class ModalInsideModal extends StatelessWidget { @@ -12,7 +11,8 @@ class ModalInsideModal extends StatelessWidget {
12 11
13 @override 12 @override
14 Widget build(BuildContext context) { 13 Widget build(BuildContext context) {
15 - return Material(child:CupertinoPageScaffold( 14 + return Material(
  15 + child: CupertinoPageScaffold(
16 navigationBar: CupertinoNavigationBar( 16 navigationBar: CupertinoNavigationBar(
17 leading: Container(), middle: Text('Modal Page')), 17 leading: Container(), middle: Text('Modal Page')),
18 child: SafeArea( 18 child: SafeArea(
@@ -33,14 +33,12 @@ class ModalInsideModal extends StatelessWidget { @@ -33,14 +33,12 @@ class ModalInsideModal extends StatelessWidget {
33 context: context, 33 context: context,
34 backgroundColor: Colors.transparent, 34 backgroundColor: Colors.transparent,
35 builder: (context, scrollController) => 35 builder: (context, scrollController) =>
36 - ModalInsideModal(scrollController: scrollController), 36 + ModalInsideModal(
  37 + scrollController: scrollController),
37 )), 38 )),
38 -  
39 - )  
40 - ).toList(), 39 + )).toList(),
41 ), 40 ),
42 ), 41 ),
43 )); 42 ));
44 } 43 }
45 } 44 }
46 -  
1 import 'package:flutter/cupertino.dart'; 1 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
  3 +
3 class SimpleModal extends StatelessWidget { 4 class SimpleModal extends StatelessWidget {
4 final ScrollController scrollController; 5 final ScrollController scrollController;
5 6
@@ -7,7 +8,8 @@ class SimpleModal extends StatelessWidget { @@ -7,7 +8,8 @@ class SimpleModal extends StatelessWidget {
7 8
8 @override 9 @override
9 Widget build(BuildContext context) { 10 Widget build(BuildContext context) {
10 - return Material(child:CupertinoPageScaffold( 11 + return Material(
  12 + child: CupertinoPageScaffold(
11 navigationBar: CupertinoNavigationBar( 13 navigationBar: CupertinoNavigationBar(
12 leading: Container(), middle: Text('Modal Page')), 14 leading: Container(), middle: Text('Modal Page')),
13 child: Center(), 15 child: Center(),
@@ -8,7 +8,8 @@ class ModalWillScope extends StatelessWidget { @@ -8,7 +8,8 @@ class ModalWillScope extends StatelessWidget {
8 8
9 @override 9 @override
10 Widget build(BuildContext context) { 10 Widget build(BuildContext context) {
11 - return Material(child: WillPopScope( 11 + return Material(
  12 + child: WillPopScope(
12 onWillPop: () async { 13 onWillPop: () async {
13 bool shouldClose = true; 14 bool shouldClose = true;
14 await showCupertinoDialog( 15 await showCupertinoDialog(
1 -  
2 import 'package:flutter/cupertino.dart'; 1 import 'package:flutter/cupertino.dart';
3 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
4 3
@@ -9,7 +8,8 @@ class ModalWithNavigator extends StatelessWidget { @@ -9,7 +8,8 @@ class ModalWithNavigator extends StatelessWidget {
9 8
10 @override 9 @override
11 Widget build(BuildContext context) { 10 Widget build(BuildContext context) {
12 - return Material( child: Navigator( 11 + return Material(
  12 + child: Navigator(
13 onGenerateRoute: (_) => MaterialPageRoute( 13 onGenerateRoute: (_) => MaterialPageRoute(
14 builder: (context) => Builder( 14 builder: (context) => Builder(
15 builder: (context) => CupertinoPageScaffold( 15 builder: (context) => CupertinoPageScaffold(
@@ -27,20 +27,14 @@ class ModalWithNavigator extends StatelessWidget { @@ -27,20 +27,14 @@ class ModalWithNavigator extends StatelessWidget {
27 (index) => ListTile( 27 (index) => ListTile(
28 title: Text('Item'), 28 title: Text('Item'),
29 onTap: () { 29 onTap: () {
30 - Navigator.of(context).push(  
31 - MaterialPageRoute(  
32 - builder: (context) =>  
33 - CupertinoPageScaffold(  
34 - navigationBar:  
35 - CupertinoNavigationBar(  
36 - middle: Text(  
37 - 'New Page'), 30 + Navigator.of(context).push(MaterialPageRoute(
  31 + builder: (context) => CupertinoPageScaffold(
  32 + navigationBar: CupertinoNavigationBar(
  33 + middle: Text('New Page'),
38 ), 34 ),
39 child: Stack( 35 child: Stack(
40 - fit:  
41 - StackFit.expand,  
42 - children: <  
43 - Widget>[], 36 + fit: StackFit.expand,
  37 + children: <Widget>[],
44 )))); 38 ))));
45 }, 39 },
46 )), 40 )),
@@ -49,8 +43,7 @@ class ModalWithNavigator extends StatelessWidget { @@ -49,8 +43,7 @@ class ModalWithNavigator extends StatelessWidget {
49 ), 43 ),
50 ), 44 ),
51 ), 45 ),
52 - ),)  
53 - ); 46 + ),
  47 + ));
54 } 48 }
55 } 49 }
56 -  
@@ -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.13" 10 + version: "2.0.11"
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.6.0" 17 + version: "1.5.2"
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.1" 24 + version: "2.4.0"
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: "2.0.0" 31 + version: "1.0.5"
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.3" 38 + version: "1.1.2"
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.12" 45 + version: "1.14.11"
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.4" 59 + version: "2.1.3"
60 cupertino_icons: 60 cupertino_icons:
61 dependency: "direct main" 61 dependency: "direct main"
62 description: 62 description:
@@ -80,7 +80,7 @@ packages: @@ -80,7 +80,7 @@ packages:
80 name: image 80 name: image
81 url: "https://pub.dartlang.org" 81 url: "https://pub.dartlang.org"
82 source: hosted 82 source: hosted
83 - version: "2.1.12" 83 + version: "2.1.4"
84 matcher: 84 matcher:
85 dependency: transitive 85 dependency: transitive
86 description: 86 description:
@@ -101,7 +101,7 @@ packages: @@ -101,7 +101,7 @@ packages:
101 path: ".." 101 path: ".."
102 relative: true 102 relative: true
103 source: path 103 source: path
104 - version: "0.0.1" 104 + version: "0.1.0"
105 path: 105 path:
106 dependency: transitive 106 dependency: transitive
107 description: 107 description:
@@ -109,6 +109,13 @@ packages: @@ -109,6 +109,13 @@ packages:
109 url: "https://pub.dartlang.org" 109 url: "https://pub.dartlang.org"
110 source: hosted 110 source: hosted
111 version: "1.6.4" 111 version: "1.6.4"
  112 + pedantic:
  113 + dependency: transitive
  114 + description:
  115 + name: pedantic
  116 + url: "https://pub.dartlang.org"
  117 + source: hosted
  118 + version: "1.8.0+1"
112 petitparser: 119 petitparser:
113 dependency: transitive 120 dependency: transitive
114 description: 121 description:
@@ -122,7 +129,7 @@ packages: @@ -122,7 +129,7 @@ packages:
122 name: quiver 129 name: quiver
123 url: "https://pub.dartlang.org" 130 url: "https://pub.dartlang.org"
124 source: hosted 131 source: hosted
125 - version: "2.1.3" 132 + version: "2.0.5"
126 sky_engine: 133 sky_engine:
127 dependency: transitive 134 dependency: transitive
128 description: flutter 135 description: flutter
@@ -134,7 +141,7 @@ packages: @@ -134,7 +141,7 @@ packages:
134 name: source_span 141 name: source_span
135 url: "https://pub.dartlang.org" 142 url: "https://pub.dartlang.org"
136 source: hosted 143 source: hosted
137 - version: "1.7.0" 144 + version: "1.5.5"
138 stack_trace: 145 stack_trace:
139 dependency: transitive 146 dependency: transitive
140 description: 147 description:
@@ -169,7 +176,7 @@ packages: @@ -169,7 +176,7 @@ packages:
169 name: test_api 176 name: test_api
170 url: "https://pub.dartlang.org" 177 url: "https://pub.dartlang.org"
171 source: hosted 178 source: hosted
172 - version: "0.2.15" 179 + version: "0.2.11"
173 typed_data: 180 typed_data:
174 dependency: transitive 181 dependency: transitive
175 description: 182 description:
@@ -190,6 +197,6 @@ packages: @@ -190,6 +197,6 @@ packages:
190 name: xml 197 name: xml
191 url: "https://pub.dartlang.org" 198 url: "https://pub.dartlang.org"
192 source: hosted 199 source: hosted
193 - version: "3.6.1" 200 + version: "3.5.0"
194 sdks: 201 sdks:
195 - dart: ">=2.7.0 <3.0.0" 202 + dart: ">=2.4.0 <3.0.0"
@@ -4,5 +4,3 @@ @@ -4,5 +4,3 @@
4 // utility that Flutter provides. For example, you can send tap and scroll 4 // utility that Flutter provides. For example, you can send tap and scroll
5 // gestures. You can also use WidgetTester to find child widgets in the widget 5 // gestures. You can also use WidgetTester to find child widgets in the widget
6 // tree, read text, and verify that the values of widget properties are correct. 6 // tree, read text, and verify that the values of widget properties are correct.
7 -  
8 -  
1 -  
2 export 'src/bottom_sheet.dart'; 1 export 'src/bottom_sheet.dart';
3 export 'src/bottom_sheet_route.dart'; 2 export 'src/bottom_sheet_route.dart';
4 export 'src/material_with_modal_page_route.dart'; 3 export 'src/material_with_modal_page_route.dart';
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 -import 'dart:math';  
7 6
8 import 'package:flutter/cupertino.dart'; 7 import 'package:flutter/cupertino.dart';
9 import 'package:flutter/foundation.dart'; 8 import 'package:flutter/foundation.dart';
@@ -12,8 +11,6 @@ import 'package:flutter/material.dart'; @@ -12,8 +11,6 @@ import 'package:flutter/material.dart';
12 import 'package:flutter/scheduler.dart'; 11 import 'package:flutter/scheduler.dart';
13 import 'package:flutter/widgets.dart'; 12 import 'package:flutter/widgets.dart';
14 13
15 -import 'bottom_sheet_route.dart';  
16 -  
17 const Duration _bottomSheetDuration = Duration(milliseconds: 400); 14 const Duration _bottomSheetDuration = Duration(milliseconds: 400);
18 const double _minFlingVelocity = 500.0; 15 const double _minFlingVelocity = 500.0;
19 const double _closeProgressThreshold = 0.5; 16 const double _closeProgressThreshold = 0.5;
@@ -158,8 +155,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -158,8 +155,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
158 155
159 bool _isCheckingShouldClose = false; 156 bool _isCheckingShouldClose = false;
160 FutureOr<bool> shouldClose() async { 157 FutureOr<bool> shouldClose() async {
161 - if(_isCheckingShouldClose) return false;  
162 - if(widget.shouldClose == null) return null; 158 + if (_isCheckingShouldClose) return false;
  159 + if (widget.shouldClose == null) return null;
163 _isCheckingShouldClose = true; 160 _isCheckingShouldClose = true;
164 final result = await widget.shouldClose(); 161 final result = await widget.shouldClose();
165 _isCheckingShouldClose = false; 162 _isCheckingShouldClose = false;
@@ -203,7 +200,6 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -203,7 +200,6 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
203 isDragging = false; 200 isDragging = false;
204 _bounceDragController.reverse(); 201 _bounceDragController.reverse();
205 202
206 -  
207 bool canClose = true; 203 bool canClose = true;
208 if (widget.shouldClose != null && hasReachedWillPopThreshold) { 204 if (widget.shouldClose != null && hasReachedWillPopThreshold) {
209 _cancelClose(); 205 _cancelClose();
@@ -273,20 +269,18 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -273,20 +269,18 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
273 child, 269 child,
274 ); 270 );
275 271
276 -  
277 // Todo: Add curved Animation when push and pop without gesture 272 // Todo: Add curved Animation when push and pop without gesture
278 - final Animation<double> containerAnimation = CurvedAnimation( 273 + /* final Animation<double> containerAnimation = CurvedAnimation(
279 parent: widget.animationController, 274 parent: widget.animationController,
280 curve: Curves.easeOut, 275 curve: Curves.easeOut,
281 - ); 276 + );*/
282 277
283 return AnimatedBuilder( 278 return AnimatedBuilder(
284 animation: widget.animationController, 279 animation: widget.animationController,
285 builder: (context, _) => ClipRect( 280 builder: (context, _) => ClipRect(
286 child: CustomSingleChildLayout( 281 child: CustomSingleChildLayout(
287 delegate: _ModalBottomSheetLayout( 282 delegate: _ModalBottomSheetLayout(
288 - widget.animationController.value,  
289 - widget.expanded), 283 + widget.animationController.value, widget.expanded),
290 child: !widget.enableDrag 284 child: !widget.enableDrag
291 ? child 285 ? child
292 : KeyedSubtree( 286 : KeyedSubtree(
1 import 'dart:async'; 1 import 'dart:async';
2 2
3 import 'package:flutter/cupertino.dart'; 3 import 'package:flutter/cupertino.dart';
4 -import 'package:flutter/foundation.dart';  
5 -import 'package:flutter/gestures.dart';  
6 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
7 -import 'package:flutter/scheduler.dart';  
8 -import 'package:flutter/widgets.dart';  
9 5
10 import '../modal_bottom_sheet.dart'; 6 import '../modal_bottom_sheet.dart';
11 -import 'material_with_modal_page_route.dart';  
12 7
13 const Duration _bottomSheetDuration = Duration(milliseconds: 400); 8 const Duration _bottomSheetDuration = Duration(milliseconds: 400);
14 9
15 -class _ModalBottomSheetLayout extends SingleChildLayoutDelegate {  
16 - _ModalBottomSheetLayout(this.progress, this.expand);  
17 -  
18 - final double progress;  
19 - final bool expand;  
20 -  
21 - @override  
22 - BoxConstraints getConstraintsForChild(BoxConstraints constraints) {  
23 - return BoxConstraints(  
24 - minWidth: constraints.maxWidth,  
25 - maxWidth: constraints.maxWidth,  
26 - minHeight: expand ? constraints.maxHeight : 0,  
27 - maxHeight: expand ? constraints.maxHeight : constraints.minHeight,  
28 - );  
29 - }  
30 -  
31 - @override  
32 - Offset getPositionForChild(Size size, Size childSize) {  
33 - return Offset(0.0, size.height - childSize.height * progress);  
34 - }  
35 -  
36 - @override  
37 - bool shouldRelayout(_ModalBottomSheetLayout oldDelegate) {  
38 - return progress != oldDelegate.progress;  
39 - }  
40 -}  
41 -  
42 class _ModalBottomSheet<T> extends StatefulWidget { 10 class _ModalBottomSheet<T> extends StatefulWidget {
43 const _ModalBottomSheet({ 11 const _ModalBottomSheet({
44 Key key, 12 Key key,
@@ -65,13 +33,14 @@ class _ModalBottomSheet<T> extends StatefulWidget { @@ -65,13 +33,14 @@ class _ModalBottomSheet<T> extends StatefulWidget {
65 33
66 class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { 34 class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
67 String _getRouteLabel(MaterialLocalizations localizations) { 35 String _getRouteLabel(MaterialLocalizations localizations) {
68 - switch (Theme.of(context).platform) { 36 + final platform = Theme.of(context).platform;
  37 + switch (platform) {
69 case TargetPlatform.iOS: 38 case TargetPlatform.iOS:
70 - case TargetPlatform.macOS:  
71 return ''; 39 return '';
72 case TargetPlatform.android: 40 case TargetPlatform.android:
73 case TargetPlatform.fuchsia: 41 case TargetPlatform.fuchsia:
74 return localizations.dialogLabel; 42 return localizations.dialogLabel;
  43 + break;
75 } 44 }
76 return null; 45 return null;
77 } 46 }
@@ -100,9 +69,6 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -100,9 +69,6 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
100 MaterialLocalizations.of(context); 69 MaterialLocalizations.of(context);
101 final String routeLabel = _getRouteLabel(localizations); 70 final String routeLabel = _getRouteLabel(localizations);
102 71
103 -  
104 -  
105 -  
106 return AnimatedBuilder( 72 return AnimatedBuilder(
107 animation: widget.route._animationController, 73 animation: widget.route._animationController,
108 builder: (BuildContext context, Widget child) { 74 builder: (BuildContext context, Widget child) {
@@ -117,7 +83,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -117,7 +83,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
117 expanded: widget.route.expanded, 83 expanded: widget.route.expanded,
118 containerBuilder: widget.route.containerBuilder, 84 containerBuilder: widget.route.containerBuilder,
119 animationController: widget.route._animationController, 85 animationController: widget.route._animationController,
120 - shouldClose: widget.route.hasScopedWillPopCallback 86 + shouldClose: widget.route._hasScopedWillPopCallback
121 ? () async { 87 ? () async {
122 final willPop = await widget.route.willPop(); 88 final willPop = await widget.route.willPop();
123 return willPop != RoutePopDisposition.doNotPop; 89 return willPop != RoutePopDisposition.doNotPop;
@@ -132,8 +98,6 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -132,8 +98,6 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
132 enableDrag: widget.enableDrag, 98 enableDrag: widget.enableDrag,
133 bounce: widget.bounce, 99 bounce: widget.bounce,
134 ), 100 ),
135 -  
136 -  
137 ); 101 );
138 }, 102 },
139 ); 103 );
@@ -191,6 +155,8 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -191,6 +155,8 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
191 return _animationController; 155 return _animationController;
192 } 156 }
193 157
  158 + bool get _hasScopedWillPopCallback => hasScopedWillPopCallback;
  159 +
194 @override 160 @override
195 Widget buildPage(BuildContext context, Animation<double> animation, 161 Widget buildPage(BuildContext context, Animation<double> animation,
196 Animation<double> secondaryAnimation) { 162 Animation<double> secondaryAnimation) {
1 -  
2 -  
3 -  
4 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
5 import 'package:flutter/services.dart'; 2 import 'package:flutter/services.dart';
  3 +import 'dart:async';
6 4
7 import '../../modal_bottom_sheet.dart'; 5 import '../../modal_bottom_sheet.dart';
8 import '../bottom_sheet_route.dart'; 6 import '../bottom_sheet_route.dart';
@@ -49,16 +47,12 @@ class BarBottomSheet extends StatelessWidget { @@ -49,16 +47,12 @@ class BarBottomSheet extends StatelessWidget {
49 ]), 47 ]),
50 width: double.infinity, 48 width: double.infinity,
51 child: MediaQuery.removePadding( 49 child: MediaQuery.removePadding(
52 - context: context,  
53 - removeTop: true,  
54 - child: child  
55 - )  
56 - ), 50 + context: context, removeTop: true, child: child)),
57 ), 51 ),
58 ), 52 ),
59 - ]),); 53 + ]),
  54 + );
60 } 55 }
61 -  
62 } 56 }
63 57
64 Future<T> showBarModalBottomSheet<T>({ 58 Future<T> showBarModalBottomSheet<T>({
@@ -88,7 +82,9 @@ Future<T> showBarModalBottomSheet<T>({ @@ -88,7 +82,9 @@ Future<T> showBarModalBottomSheet<T>({
88 .push(ModalBottomSheetRoute<T>( 82 .push(ModalBottomSheetRoute<T>(
89 builder: builder, 83 builder: builder,
90 bounce: bounce, 84 bounce: bounce,
91 - containerBuilder: (_, __, child) => BarBottomSheet(child: child,), 85 + containerBuilder: (_, __, child) => BarBottomSheet(
  86 + child: child,
  87 + ),
92 secondAnimationController: secondAnimation, 88 secondAnimationController: secondAnimation,
93 expanded: expand, 89 expanded: expand,
94 barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, 90 barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
@@ -98,4 +94,3 @@ Future<T> showBarModalBottomSheet<T>({ @@ -98,4 +94,3 @@ Future<T> showBarModalBottomSheet<T>({
98 )); 94 ));
99 return result; 95 return result;
100 } 96 }
101 -  
@@ -8,7 +8,6 @@ import 'package:flutter/cupertino.dart'; @@ -8,7 +8,6 @@ import 'package:flutter/cupertino.dart';
8 import 'package:flutter/foundation.dart'; 8 import 'package:flutter/foundation.dart';
9 import 'package:flutter/gestures.dart'; 9 import 'package:flutter/gestures.dart';
10 import 'package:flutter/material.dart'; 10 import 'package:flutter/material.dart';
11 -import 'package:flutter/scheduler.dart';  
12 import 'package:flutter/services.dart'; 11 import 'package:flutter/services.dart';
13 import 'package:flutter/widgets.dart'; 12 import 'package:flutter/widgets.dart';
14 13
@@ -200,7 +199,9 @@ class _CupertinoModalTransition extends StatelessWidget { @@ -200,7 +199,9 @@ class _CupertinoModalTransition extends StatelessWidget {
200 final progress = curvedAnimation.value; 199 final progress = curvedAnimation.value;
201 final yOffset = progress * paddingTop; 200 final yOffset = progress * paddingTop;
202 final scale = 1 - progress / 10; 201 final scale = 1 - progress / 10;
203 - final radius = progress == 0 ? 0.0 : (1 - progress) * startRoundCorner + progress * 12; 202 + final radius = progress == 0
  203 + ? 0.0
  204 + : (1 - progress) * startRoundCorner + progress * 12;
204 return Stack( 205 return Stack(
205 children: <Widget>[ 206 children: <Widget>[
206 Container(color: Colors.black), 207 Container(color: Colors.black),
1 -  
2 -  
3 -  
4 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
5 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; 2 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
  3 +import 'dart:async';
6 4
7 /// Shows a modal material design bottom sheet. 5 /// Shows a modal material design bottom sheet.
8 Future<T> showMaterialModalBottomSheet<T>({ 6 Future<T> showMaterialModalBottomSheet<T>({
1 import 'package:flutter/cupertino.dart'; 1 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/foundation.dart'; 2 import 'package:flutter/foundation.dart';
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
4 -import 'package:flutter/services.dart';  
5 4
6 import '../modal_bottom_sheet.dart'; 5 import '../modal_bottom_sheet.dart';
7 import 'bottom_sheet_route.dart'; 6 import 'bottom_sheet_route.dart';
8 7
9 -class e extends PageRouteBuilder {  
10 -  
11 -}  
12 -  
13 class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { 8 class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> {
14 /// Construct a MaterialPageRoute whose contents are defined by [builder]. 9 /// Construct a MaterialPageRoute whose contents are defined by [builder].
15 /// 10 ///
@@ -30,8 +25,6 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { @@ -30,8 +25,6 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> {
30 builder: builder, 25 builder: builder,
31 maintainState: maintainState); 26 maintainState: maintainState);
32 27
33 -  
34 -  
35 ModalBottomSheetRoute _nextModalRoute; 28 ModalBottomSheetRoute _nextModalRoute;
36 29
37 @override 30 @override
@@ -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.13" 10 + version: "2.0.11"
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.6.0" 17 + version: "1.5.2"
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.1" 24 + version: "2.4.0"
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: "2.0.0" 31 + version: "1.0.5"
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.3" 38 + version: "1.1.2"
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.12" 45 + version: "1.14.11"
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.4" 59 + version: "2.1.3"
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.12" 76 + version: "2.1.4"
77 matcher: 77 matcher:
78 dependency: transitive 78 dependency: transitive
79 description: 79 description:
@@ -95,6 +95,13 @@ packages: @@ -95,6 +95,13 @@ packages:
95 url: "https://pub.dartlang.org" 95 url: "https://pub.dartlang.org"
96 source: hosted 96 source: hosted
97 version: "1.6.4" 97 version: "1.6.4"
  98 + pedantic:
  99 + dependency: transitive
  100 + description:
  101 + name: pedantic
  102 + url: "https://pub.dartlang.org"
  103 + source: hosted
  104 + version: "1.8.0+1"
98 petitparser: 105 petitparser:
99 dependency: transitive 106 dependency: transitive
100 description: 107 description:
@@ -108,7 +115,7 @@ packages: @@ -108,7 +115,7 @@ packages:
108 name: quiver 115 name: quiver
109 url: "https://pub.dartlang.org" 116 url: "https://pub.dartlang.org"
110 source: hosted 117 source: hosted
111 - version: "2.1.3" 118 + version: "2.0.5"
112 sky_engine: 119 sky_engine:
113 dependency: transitive 120 dependency: transitive
114 description: flutter 121 description: flutter
@@ -120,7 +127,7 @@ packages: @@ -120,7 +127,7 @@ packages:
120 name: source_span 127 name: source_span
121 url: "https://pub.dartlang.org" 128 url: "https://pub.dartlang.org"
122 source: hosted 129 source: hosted
123 - version: "1.7.0" 130 + version: "1.5.5"
124 stack_trace: 131 stack_trace:
125 dependency: transitive 132 dependency: transitive
126 description: 133 description:
@@ -155,7 +162,7 @@ packages: @@ -155,7 +162,7 @@ packages:
155 name: test_api 162 name: test_api
156 url: "https://pub.dartlang.org" 163 url: "https://pub.dartlang.org"
157 source: hosted 164 source: hosted
158 - version: "0.2.15" 165 + version: "0.2.11"
159 typed_data: 166 typed_data:
160 dependency: transitive 167 dependency: transitive
161 description: 168 description:
@@ -176,6 +183,6 @@ packages: @@ -176,6 +183,6 @@ packages:
176 name: xml 183 name: xml
177 url: "https://pub.dartlang.org" 184 url: "https://pub.dartlang.org"
178 source: hosted 185 source: hosted
179 - version: "3.6.1" 186 + version: "3.5.0"
180 sdks: 187 sdks:
181 - dart: ">=2.7.0 <3.0.0" 188 + dart: ">=2.4.0 <3.0.0"
1 name: modal_bottom_sheet 1 name: modal_bottom_sheet
2 -description: 'Modal bottom sheets: Cupertino, Material, or build your own'  
3 -version: 0.0.1  
4 -author: 'JB <git@jaimeblasco.com>' 2 +description: 'Create flutter advanced modal bottom sheets. Material, Cupertino or your own style'
  3 +version: 0.1.3
5 homepage: 'https://github.com/jamesblasco/modal_bottom_sheet' 4 homepage: 'https://github.com/jamesblasco/modal_bottom_sheet'
6 5
7 environment: 6 environment:
8 - sdk: ">=2.7.0 <3.0.0" 7 + sdk: ">=2.0.0 <3.0.0"
  8 + flutter: ">=1.12.0 <2.0.0"
9 9
10 dependencies: 10 dependencies:
11 flutter: 11 flutter:
1 import 'package:flutter_test/flutter_test.dart'; 1 import 'package:flutter_test/flutter_test.dart';
2 2
3 -  
4 -  
5 void main() { 3 void main() {
6 - test('adds one to input values', () {  
7 -  
8 - }); 4 + test('adds one to input values', () {});
9 } 5 }