Jaime Blasco
Committed by GitHub

feat: pop scope (#437)

@@ -20,7 +20,7 @@ Why not `showModalBottomSheet`? @@ -20,7 +20,7 @@ Why not `showModalBottomSheet`?
20 Inspired by `showModalBottomSheet`, it completes with some must-need features: 20 Inspired by `showModalBottomSheet`, it completes with some must-need features:
21 21
22 - Support for inside scrollview + dragging down to close (`showModalBottomSheet` won't work correctly with scrollviews. 22 - Support for inside scrollview + dragging down to close (`showModalBottomSheet` won't work correctly with scrollviews.
23 -- Support for `WillPopScope` to prevent closing the dialog. 23 +- Support for `PopScope` and `WillPopScope` to prevent closing the dialog.
24 - Support for scroll to top when tapping status bar (iOS only) 24 - Support for scroll to top when tapping status bar (iOS only)
25 - Support for top SafeArea (not supported by showModalBottomSheet) 25 - Support for top SafeArea (not supported by showModalBottomSheet)
26 - Cupertino modal bottom sheet 26 - Cupertino modal bottom sheet
@@ -21,6 +21,6 @@ @@ -21,6 +21,6 @@
21 <key>CFBundleVersion</key> 21 <key>CFBundleVersion</key>
22 <string>1.0</string> 22 <string>1.0</string>
23 <key>MinimumOSVersion</key> 23 <key>MinimumOSVersion</key>
24 - <string>11.0</string> 24 + <string>12.0</string>
25 </dict> 25 </dict>
26 </plist> 26 </plist>
1 # Uncomment this line to define a global platform for your project 1 # Uncomment this line to define a global platform for your project
2 -# platform :ios, '11.0' 2 +# platform :ios, '12.0'
3 3
4 # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 ENV['COCOAPODS_DISABLE_STATS'] = 'true'
@@ -14,9 +14,9 @@ EXTERNAL SOURCES: @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
14 :path: ".symlinks/plugins/url_launcher_ios/ios" 14 :path: ".symlinks/plugins/url_launcher_ios/ios"
15 15
16 SPEC CHECKSUMS: 16 SPEC CHECKSUMS:
17 - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 17 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
18 url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86 18 url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86
19 19
20 -PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 20 +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011
21 21
22 -COCOAPODS: 1.14.3 22 +COCOAPODS: 1.15.2
@@ -155,7 +155,7 @@ @@ -155,7 +155,7 @@
155 97C146E61CF9000F007C117D /* Project object */ = { 155 97C146E61CF9000F007C117D /* Project object */ = {
156 isa = PBXProject; 156 isa = PBXProject;
157 attributes = { 157 attributes = {
158 - LastUpgradeCheck = 1430; 158 + LastUpgradeCheck = 1510;
159 ORGANIZATIONNAME = ""; 159 ORGANIZATIONNAME = "";
160 TargetAttributes = { 160 TargetAttributes = {
161 97C146ED1CF9000F007C117D = { 161 97C146ED1CF9000F007C117D = {
@@ -342,7 +342,7 @@ @@ -342,7 +342,7 @@
342 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 342 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
343 GCC_WARN_UNUSED_FUNCTION = YES; 343 GCC_WARN_UNUSED_FUNCTION = YES;
344 GCC_WARN_UNUSED_VARIABLE = YES; 344 GCC_WARN_UNUSED_VARIABLE = YES;
345 - IPHONEOS_DEPLOYMENT_TARGET = 11.0; 345 + IPHONEOS_DEPLOYMENT_TARGET = 12.0;
346 MTL_ENABLE_DEBUG_INFO = NO; 346 MTL_ENABLE_DEBUG_INFO = NO;
347 SDKROOT = iphoneos; 347 SDKROOT = iphoneos;
348 SUPPORTED_PLATFORMS = iphoneos; 348 SUPPORTED_PLATFORMS = iphoneos;
@@ -420,7 +420,7 @@ @@ -420,7 +420,7 @@
420 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
421 GCC_WARN_UNUSED_FUNCTION = YES; 421 GCC_WARN_UNUSED_FUNCTION = YES;
422 GCC_WARN_UNUSED_VARIABLE = YES; 422 GCC_WARN_UNUSED_VARIABLE = YES;
423 - IPHONEOS_DEPLOYMENT_TARGET = 11.0; 423 + IPHONEOS_DEPLOYMENT_TARGET = 12.0;
424 MTL_ENABLE_DEBUG_INFO = YES; 424 MTL_ENABLE_DEBUG_INFO = YES;
425 ONLY_ACTIVE_ARCH = YES; 425 ONLY_ACTIVE_ARCH = YES;
426 SDKROOT = iphoneos; 426 SDKROOT = iphoneos;
@@ -469,7 +469,7 @@ @@ -469,7 +469,7 @@
469 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 469 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
470 GCC_WARN_UNUSED_FUNCTION = YES; 470 GCC_WARN_UNUSED_FUNCTION = YES;
471 GCC_WARN_UNUSED_VARIABLE = YES; 471 GCC_WARN_UNUSED_VARIABLE = YES;
472 - IPHONEOS_DEPLOYMENT_TARGET = 11.0; 472 + IPHONEOS_DEPLOYMENT_TARGET = 12.0;
473 MTL_ENABLE_DEBUG_INFO = NO; 473 MTL_ENABLE_DEBUG_INFO = NO;
474 SDKROOT = iphoneos; 474 SDKROOT = iphoneos;
475 SUPPORTED_PLATFORMS = iphoneos; 475 SUPPORTED_PLATFORMS = iphoneos;
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <Scheme 2 <Scheme
3 - LastUpgradeVersion = "1430" 3 + LastUpgradeVersion = "1510"
4 version = "1.3"> 4 version = "1.3">
5 <BuildAction 5 <BuildAction
6 parallelizeBuildables = "YES" 6 parallelizeBuildables = "YES"
@@ -208,8 +208,7 @@ class _MyHomePageState extends State<MyHomePage> { @@ -208,8 +208,7 @@ class _MyHomePageState extends State<MyHomePage> {
208 builder: (context) => ModalWithNavigator(), 208 builder: (context) => ModalWithNavigator(),
209 )), 209 )),
210 ListTile( 210 ListTile(
211 - title:  
212 - Text('Cupertino Navigator + Scroll + WillPopScope'), 211 + title: Text('Cupertino Navigator + Scroll + PopScope'),
213 onTap: () => showCupertinoModalBottomSheet( 212 onTap: () => showCupertinoModalBottomSheet(
214 expand: true, 213 expand: true,
215 context: context, 214 context: context,
@@ -218,7 +217,7 @@ class _MyHomePageState extends State<MyHomePage> { @@ -218,7 +217,7 @@ class _MyHomePageState extends State<MyHomePage> {
218 ), 217 ),
219 ), 218 ),
220 ListTile( 219 ListTile(
221 - title: Text('Modal with WillPopScope'), 220 + title: Text('Modal with PopScope'),
222 onTap: () => showCupertinoModalBottomSheet( 221 onTap: () => showCupertinoModalBottomSheet(
223 expand: true, 222 expand: true,
224 context: context, 223 context: context,
@@ -8,31 +8,33 @@ class ComplexModal extends StatelessWidget { @@ -8,31 +8,33 @@ class ComplexModal extends StatelessWidget {
8 @override 8 @override
9 Widget build(BuildContext context) { 9 Widget build(BuildContext context) {
10 return Material( 10 return Material(
11 - child: WillPopScope(  
12 - onWillPop: () async {  
13 - bool shouldClose = true;  
14 - await showCupertinoDialog(  
15 - context: context,  
16 - builder: (context) => CupertinoAlertDialog(  
17 - title: Text('Should Close?'),  
18 - actions: <Widget>[  
19 - CupertinoButton(  
20 - child: Text('Yes'),  
21 - onPressed: () {  
22 - shouldClose = true;  
23 - Navigator.of(context).pop();  
24 - },  
25 - ),  
26 - CupertinoButton(  
27 - child: Text('No'),  
28 - onPressed: () {  
29 - shouldClose = false;  
30 - Navigator.of(context).pop();  
31 - },  
32 - ),  
33 - ],  
34 - ));  
35 - return shouldClose; 11 + child: PopScope(
  12 + canPop: false,
  13 + onPopInvoked: (didPop) {
  14 + if (!didPop) {
  15 + final sheetNavigator = Navigator.of(context);
  16 +
  17 + showCupertinoDialog(
  18 + context: context,
  19 + builder: (context) => CupertinoAlertDialog(
  20 + title: Text('Should Close?'),
  21 + actions: <Widget>[
  22 + CupertinoButton(
  23 + child: Text('Yes'),
  24 + onPressed: () {
  25 + Navigator.of(context).pop();
  26 + sheetNavigator.pop();
  27 + },
  28 + ),
  29 + CupertinoButton(
  30 + child: Text('No'),
  31 + onPressed: () {
  32 + Navigator.of(context).pop();
  33 + },
  34 + ),
  35 + ],
  36 + ));
  37 + }
36 }, 38 },
37 child: Navigator( 39 child: Navigator(
38 onGenerateRoute: (_) => MaterialPageRoute( 40 onGenerateRoute: (_) => MaterialPageRoute(
@@ -7,31 +7,32 @@ class ModalWillScope extends StatelessWidget { @@ -7,31 +7,32 @@ class ModalWillScope extends StatelessWidget {
7 @override 7 @override
8 Widget build(BuildContext context) { 8 Widget build(BuildContext context) {
9 return Material( 9 return Material(
10 - child: WillPopScope(  
11 - onWillPop: () async {  
12 - bool shouldClose = true;  
13 - await showCupertinoDialog(  
14 - context: context,  
15 - builder: (context) => CupertinoAlertDialog(  
16 - title: Text('Should Close?'),  
17 - actions: <Widget>[  
18 - CupertinoButton(  
19 - child: Text('Yes'),  
20 - onPressed: () {  
21 - shouldClose = true;  
22 - Navigator.of(context).pop();  
23 - },  
24 - ),  
25 - CupertinoButton(  
26 - child: Text('No'),  
27 - onPressed: () {  
28 - shouldClose = false;  
29 - Navigator.of(context).pop();  
30 - },  
31 - ),  
32 - ],  
33 - ));  
34 - return shouldClose; 10 + child: PopScope(
  11 + canPop: false,
  12 + onPopInvoked: (didPop) {
  13 + if (didPop) return;
  14 + final sheetNavigator = Navigator.of(context);
  15 + showCupertinoDialog(
  16 + context: context,
  17 + builder: (context) => CupertinoAlertDialog(
  18 + title: Text('Should Close?'),
  19 + actions: <Widget>[
  20 + CupertinoButton(
  21 + child: Text('Yes'),
  22 + onPressed: () {
  23 + Navigator.of(context).pop();
  24 + },
  25 + ),
  26 + CupertinoButton(
  27 + child: Text('No'),
  28 + onPressed: () {
  29 + Navigator.of(context).pop();
  30 + sheetNavigator.pop();
  31 + },
  32 + ),
  33 + ],
  34 + ),
  35 + );
35 }, 36 },
36 child: CupertinoPageScaffold( 37 child: CupertinoPageScaffold(
37 navigationBar: CupertinoNavigationBar( 38 navigationBar: CupertinoNavigationBar(
@@ -72,6 +72,30 @@ packages: @@ -72,6 +72,30 @@ packages:
72 description: flutter 72 description: flutter
73 source: sdk 73 source: sdk
74 version: "0.0.0" 74 version: "0.0.0"
  75 + leak_tracker:
  76 + dependency: transitive
  77 + description:
  78 + name: leak_tracker
  79 + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
  80 + url: "https://pub.dev"
  81 + source: hosted
  82 + version: "10.0.0"
  83 + leak_tracker_flutter_testing:
  84 + dependency: transitive
  85 + description:
  86 + name: leak_tracker_flutter_testing
  87 + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
  88 + url: "https://pub.dev"
  89 + source: hosted
  90 + version: "2.0.1"
  91 + leak_tracker_testing:
  92 + dependency: transitive
  93 + description:
  94 + name: leak_tracker_testing
  95 + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
  96 + url: "https://pub.dev"
  97 + source: hosted
  98 + version: "2.0.1"
75 lints: 99 lints:
76 dependency: "direct dev" 100 dependency: "direct dev"
77 description: 101 description:
@@ -84,41 +108,41 @@ packages: @@ -84,41 +108,41 @@ packages:
84 dependency: transitive 108 dependency: transitive
85 description: 109 description:
86 name: matcher 110 name: matcher
87 - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" 111 + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
88 url: "https://pub.dev" 112 url: "https://pub.dev"
89 source: hosted 113 source: hosted
90 - version: "0.12.16" 114 + version: "0.12.16+1"
91 material_color_utilities: 115 material_color_utilities:
92 dependency: transitive 116 dependency: transitive
93 description: 117 description:
94 name: material_color_utilities 118 name: material_color_utilities
95 - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" 119 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
96 url: "https://pub.dev" 120 url: "https://pub.dev"
97 source: hosted 121 source: hosted
98 - version: "0.5.0" 122 + version: "0.8.0"
99 meta: 123 meta:
100 dependency: transitive 124 dependency: transitive
101 description: 125 description:
102 name: meta 126 name: meta
103 - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e 127 + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
104 url: "https://pub.dev" 128 url: "https://pub.dev"
105 source: hosted 129 source: hosted
106 - version: "1.10.0" 130 + version: "1.11.0"
107 modal_bottom_sheet: 131 modal_bottom_sheet:
108 dependency: "direct main" 132 dependency: "direct main"
109 description: 133 description:
110 path: ".." 134 path: ".."
111 relative: true 135 relative: true
112 source: path 136 source: path
113 - version: "3.0.1" 137 + version: "3.0.0"
114 path: 138 path:
115 dependency: transitive 139 dependency: transitive
116 description: 140 description:
117 name: path 141 name: path
118 - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 142 + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
119 url: "https://pub.dev" 143 url: "https://pub.dev"
120 source: hosted 144 source: hosted
121 - version: "1.8.3" 145 + version: "1.9.0"
122 plugin_platform_interface: 146 plugin_platform_interface:
123 dependency: transitive 147 dependency: transitive
124 description: 148 description:
@@ -252,14 +276,14 @@ packages: @@ -252,14 +276,14 @@ packages:
252 url: "https://pub.dev" 276 url: "https://pub.dev"
253 source: hosted 277 source: hosted
254 version: "2.1.4" 278 version: "2.1.4"
255 - web: 279 + vm_service:
256 dependency: transitive 280 dependency: transitive
257 description: 281 description:
258 - name: web  
259 - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 282 + name: vm_service
  283 + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
260 url: "https://pub.dev" 284 url: "https://pub.dev"
261 source: hosted 285 source: hosted
262 - version: "0.3.0" 286 + version: "13.0.0"
263 sdks: 287 sdks:
264 - dart: ">=3.2.0-194.0.dev <4.0.0" 288 + dart: ">=3.3.0 <4.0.0"
265 flutter: ">=3.13.0" 289 flutter: ">=3.13.0"
@@ -96,10 +96,21 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -96,10 +96,21 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
96 expanded: widget.route.expanded, 96 expanded: widget.route.expanded,
97 containerBuilder: widget.route.containerBuilder, 97 containerBuilder: widget.route.containerBuilder,
98 animationController: widget.route._animationController!, 98 animationController: widget.route._animationController!,
99 - shouldClose: widget.route._hasScopedWillPopCallback 99 + shouldClose: widget.route.popDisposition ==
  100 + RoutePopDisposition.doNotPop ||
  101 + widget.route._hasScopedWillPopCallback
100 ? () async { 102 ? () async {
  103 + // ignore: deprecated_member_use
101 final willPop = await widget.route.willPop(); 104 final willPop = await widget.route.willPop();
102 - return willPop != RoutePopDisposition.doNotPop; 105 + final popDisposition = widget.route.popDisposition;
  106 + final shouldClose =
  107 + !(willPop == RoutePopDisposition.doNotPop ||
  108 + popDisposition == RoutePopDisposition.doNotPop);
  109 + popDisposition == RoutePopDisposition.doNotPop;
  110 + if (!shouldClose) {
  111 + widget.route.onPopInvoked(false);
  112 + }
  113 + return shouldClose;
103 } 114 }
104 : null, 115 : null,
105 onClosing: () { 116 onClosing: () {
@@ -138,7 +149,7 @@ class ModalSheetRoute<T> extends PageRoute<T> { @@ -138,7 +149,7 @@ class ModalSheetRoute<T> extends PageRoute<T> {
138 this.animationCurve, 149 this.animationCurve,
139 Duration? duration, 150 Duration? duration,
140 super.settings, 151 super.settings,
141 - }) : duration = duration ?? _bottomSheetDuration; 152 + }) : duration = duration ?? _bottomSheetDuration;
142 153
143 final double? closeProgressThreshold; 154 final double? closeProgressThreshold;
144 final WidgetWithChildBuilder? containerBuilder; 155 final WidgetWithChildBuilder? containerBuilder;
@@ -21,6 +21,6 @@ @@ -21,6 +21,6 @@
21 <key>CFBundleVersion</key> 21 <key>CFBundleVersion</key>
22 <string>1.0</string> 22 <string>1.0</string>
23 <key>MinimumOSVersion</key> 23 <key>MinimumOSVersion</key>
24 - <string>11.0</string> 24 + <string>12.0</string>
25 </dict> 25 </dict>
26 </plist> 26 </plist>
@@ -127,7 +127,7 @@ @@ -127,7 +127,7 @@
127 97C146E61CF9000F007C117D /* Project object */ = { 127 97C146E61CF9000F007C117D /* Project object */ = {
128 isa = PBXProject; 128 isa = PBXProject;
129 attributes = { 129 attributes = {
130 - LastUpgradeCheck = 1430; 130 + LastUpgradeCheck = 1510;
131 ORGANIZATIONNAME = ""; 131 ORGANIZATIONNAME = "";
132 TargetAttributes = { 132 TargetAttributes = {
133 97C146ED1CF9000F007C117D = { 133 97C146ED1CF9000F007C117D = {
@@ -275,7 +275,7 @@ @@ -275,7 +275,7 @@
275 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
276 GCC_WARN_UNUSED_FUNCTION = YES; 276 GCC_WARN_UNUSED_FUNCTION = YES;
277 GCC_WARN_UNUSED_VARIABLE = YES; 277 GCC_WARN_UNUSED_VARIABLE = YES;
278 - IPHONEOS_DEPLOYMENT_TARGET = 11.0; 278 + IPHONEOS_DEPLOYMENT_TARGET = 12.0;
279 MTL_ENABLE_DEBUG_INFO = NO; 279 MTL_ENABLE_DEBUG_INFO = NO;
280 SDKROOT = iphoneos; 280 SDKROOT = iphoneos;
281 SUPPORTED_PLATFORMS = iphoneos; 281 SUPPORTED_PLATFORMS = iphoneos;
@@ -361,7 +361,7 @@ @@ -361,7 +361,7 @@
361 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
362 GCC_WARN_UNUSED_FUNCTION = YES; 362 GCC_WARN_UNUSED_FUNCTION = YES;
363 GCC_WARN_UNUSED_VARIABLE = YES; 363 GCC_WARN_UNUSED_VARIABLE = YES;
364 - IPHONEOS_DEPLOYMENT_TARGET = 11.0; 364 + IPHONEOS_DEPLOYMENT_TARGET = 12.0;
365 MTL_ENABLE_DEBUG_INFO = YES; 365 MTL_ENABLE_DEBUG_INFO = YES;
366 ONLY_ACTIVE_ARCH = YES; 366 ONLY_ACTIVE_ARCH = YES;
367 SDKROOT = iphoneos; 367 SDKROOT = iphoneos;
@@ -410,7 +410,7 @@ @@ -410,7 +410,7 @@
410 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 410 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
411 GCC_WARN_UNUSED_FUNCTION = YES; 411 GCC_WARN_UNUSED_FUNCTION = YES;
412 GCC_WARN_UNUSED_VARIABLE = YES; 412 GCC_WARN_UNUSED_VARIABLE = YES;
413 - IPHONEOS_DEPLOYMENT_TARGET = 11.0; 413 + IPHONEOS_DEPLOYMENT_TARGET = 12.0;
414 MTL_ENABLE_DEBUG_INFO = NO; 414 MTL_ENABLE_DEBUG_INFO = NO;
415 SDKROOT = iphoneos; 415 SDKROOT = iphoneos;
416 SUPPORTED_PLATFORMS = iphoneos; 416 SUPPORTED_PLATFORMS = iphoneos;
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <Scheme 2 <Scheme
3 - LastUpgradeVersion = "1430" 3 + LastUpgradeVersion = "1510"
4 version = "1.3"> 4 version = "1.3">
5 <BuildAction 5 <BuildAction
6 parallelizeBuildables = "YES" 6 parallelizeBuildables = "YES"
@@ -9,31 +9,32 @@ class ComplexModal extends StatelessWidget { @@ -9,31 +9,32 @@ class ComplexModal extends StatelessWidget {
9 final ScrollController primaryScrollController = 9 final ScrollController primaryScrollController =
10 PrimaryScrollController.maybeOf(context)!; 10 PrimaryScrollController.maybeOf(context)!;
11 return Material( 11 return Material(
12 - child: WillPopScope(  
13 - onWillPop: () async {  
14 - bool shouldClose = true;  
15 - await showCupertinoDialog<void>(  
16 - context: context,  
17 - builder: (BuildContext context) => CupertinoAlertDialog(  
18 - title: const Text('Should Close?'),  
19 - actions: <Widget>[  
20 - CupertinoButton(  
21 - child: const Text('Yes'),  
22 - onPressed: () {  
23 - shouldClose = true;  
24 - Navigator.of(context).pop();  
25 - },  
26 - ),  
27 - CupertinoButton(  
28 - child: const Text('No'),  
29 - onPressed: () {  
30 - shouldClose = false;  
31 - Navigator.of(context).pop();  
32 - },  
33 - ),  
34 - ],  
35 - ));  
36 - return shouldClose; 12 + child: PopScope(
  13 + canPop: false,
  14 + onPopInvoked: (didPop) {
  15 + final sheetNavigator = Navigator.of(context);
  16 + if (!didPop) {
  17 + showCupertinoDialog<void>(
  18 + context: context,
  19 + builder: (BuildContext context) => CupertinoAlertDialog(
  20 + title: const Text('Should Close?'),
  21 + actions: <Widget>[
  22 + CupertinoButton(
  23 + child: const Text('Yes'),
  24 + onPressed: () {
  25 + Navigator.of(context).pop();
  26 + sheetNavigator.pop();
  27 + },
  28 + ),
  29 + CupertinoButton(
  30 + child: const Text('No'),
  31 + onPressed: () {
  32 + Navigator.of(context).pop();
  33 + },
  34 + ),
  35 + ],
  36 + ));
  37 + }
37 }, 38 },
38 child: Navigator( 39 child: Navigator(
39 onGenerateRoute: (_) => MaterialPageRoute<void>( 40 onGenerateRoute: (_) => MaterialPageRoute<void>(
@@ -7,10 +7,12 @@ class ModalFitWillScope extends StatelessWidget { @@ -7,10 +7,12 @@ class ModalFitWillScope extends StatelessWidget {
7 @override 7 @override
8 Widget build(BuildContext context) { 8 Widget build(BuildContext context) {
9 return Material( 9 return Material(
10 - child: WillPopScope(  
11 - onWillPop: () async {  
12 - bool shouldClose = true;  
13 - await showCupertinoDialog<void>( 10 + child: PopScope(
  11 + canPop: false,
  12 + onPopInvoked: (didPop) {
  13 + if (didPop) return;
  14 + final sheetNavigator = Navigator.of(context);
  15 + showCupertinoDialog<void>(
14 context: context, 16 context: context,
15 builder: (BuildContext context) => CupertinoAlertDialog( 17 builder: (BuildContext context) => CupertinoAlertDialog(
16 title: const Text('Should Close?'), 18 title: const Text('Should Close?'),
@@ -18,20 +20,18 @@ class ModalFitWillScope extends StatelessWidget { @@ -18,20 +20,18 @@ class ModalFitWillScope extends StatelessWidget {
18 CupertinoButton( 20 CupertinoButton(
19 child: const Text('Yes'), 21 child: const Text('Yes'),
20 onPressed: () { 22 onPressed: () {
21 - shouldClose = true;  
22 Navigator.of(context).pop(); 23 Navigator.of(context).pop();
  24 + sheetNavigator.pop();
23 }, 25 },
24 ), 26 ),
25 CupertinoButton( 27 CupertinoButton(
26 child: const Text('No'), 28 child: const Text('No'),
27 onPressed: () { 29 onPressed: () {
28 - shouldClose = false;  
29 Navigator.of(context).pop(); 30 Navigator.of(context).pop();
30 }, 31 },
31 ), 32 ),
32 ], 33 ],
33 )); 34 ));
34 - return shouldClose;  
35 }, 35 },
36 child: Column( 36 child: Column(
37 mainAxisSize: MainAxisSize.min, 37 mainAxisSize: MainAxisSize.min,
@@ -7,31 +7,35 @@ class ModalWillScope extends StatelessWidget { @@ -7,31 +7,35 @@ class ModalWillScope extends StatelessWidget {
7 @override 7 @override
8 Widget build(BuildContext context) { 8 Widget build(BuildContext context) {
9 return Material( 9 return Material(
10 - child: WillPopScope(  
11 - onWillPop: () async {  
12 - bool shouldClose = true;  
13 - await showCupertinoDialog<void>( 10 + child: PopScope(
  11 + canPop: false,
  12 + onPopInvoked: (didPop) async {
  13 + if (didPop) {
  14 + return;
  15 + }
  16 + final sheetNavigator = Navigator.of(context);
  17 + showCupertinoDialog<void>(
14 context: context, 18 context: context,
15 - builder: (BuildContext context) => CupertinoAlertDialog(  
16 - title: const Text('Should Close?'),  
17 - actions: <Widget>[  
18 - CupertinoButton(  
19 - child: const Text('Yes'),  
20 - onPressed: () {  
21 - shouldClose = true;  
22 - Navigator.of(context).pop();  
23 - },  
24 - ),  
25 - CupertinoButton(  
26 - child: const Text('No'),  
27 - onPressed: () {  
28 - shouldClose = false;  
29 - Navigator.of(context).pop();  
30 - },  
31 - ),  
32 - ],  
33 - ));  
34 - return shouldClose; 19 + builder: (BuildContext context) {
  20 + return CupertinoAlertDialog(
  21 + title: const Text('Should Close?'),
  22 + actions: <Widget>[
  23 + CupertinoButton(
  24 + child: const Text('Yes'),
  25 + onPressed: () {
  26 + Navigator.of(context).pop();
  27 + sheetNavigator.pop();
  28 + },
  29 + ),
  30 + CupertinoButton(
  31 + child: const Text('No'),
  32 + onPressed: () {
  33 + Navigator.of(context).pop();
  34 + },
  35 + ),
  36 + ],
  37 + );
  38 + });
35 }, 39 },
36 child: CupertinoPageScaffold( 40 child: CupertinoPageScaffold(
37 navigationBar: CupertinoNavigationBar( 41 navigationBar: CupertinoNavigationBar(
@@ -3,7 +3,7 @@ import 'package:sheet/sheet.dart'; @@ -3,7 +3,7 @@ import 'package:sheet/sheet.dart';
3 3
4 class FoldableScreenFloatingSheet extends StatefulWidget { 4 class FoldableScreenFloatingSheet extends StatefulWidget {
5 @override 5 @override
6 - State<FoldableScreenFloatingSheet> createState() => _FitSheetState(); 6 + State<FoldableScreenFloatingSheet> createState() => _FitSheetState();
7 } 7 }
8 8
9 class _FitSheetState extends State<FoldableScreenFloatingSheet> { 9 class _FitSheetState extends State<FoldableScreenFloatingSheet> {
@@ -6,7 +6,7 @@ import 'package:sheet/sheet.dart'; @@ -6,7 +6,7 @@ import 'package:sheet/sheet.dart';
6 6
7 class NoMomentumSheet extends StatefulWidget { 7 class NoMomentumSheet extends StatefulWidget {
8 @override 8 @override
9 - State<NoMomentumSheet> createState() => _NoMomentumSheetState(); 9 + State<NoMomentumSheet> createState() => _NoMomentumSheetState();
10 } 10 }
11 11
12 class _NoMomentumSheetState extends State<NoMomentumSheet> { 12 class _NoMomentumSheetState extends State<NoMomentumSheet> {
@@ -6,7 +6,7 @@ import 'package:sheet/sheet.dart'; @@ -6,7 +6,7 @@ import 'package:sheet/sheet.dart';
6 6
7 class SnapSheet extends StatefulWidget { 7 class SnapSheet extends StatefulWidget {
8 @override 8 @override
9 - State<SnapSheet> createState() => _SnapSheetState(); 9 + State<SnapSheet> createState() => _SnapSheetState();
10 } 10 }
11 11
12 class _SnapSheetState extends State<SnapSheet> { 12 class _SnapSheetState extends State<SnapSheet> {
@@ -4,7 +4,7 @@ import 'package:sheet/sheet.dart'; @@ -4,7 +4,7 @@ import 'package:sheet/sheet.dart';
4 4
5 class TextFieldSheet extends StatefulWidget { 5 class TextFieldSheet extends StatefulWidget {
6 @override 6 @override
7 - State<TextFieldSheet> createState() => _TextFieldSheetState(); 7 + State<TextFieldSheet> createState() => _TextFieldSheetState();
8 } 8 }
9 9
10 class _TextFieldSheetState extends State<TextFieldSheet> 10 class _TextFieldSheetState extends State<TextFieldSheet>
@@ -234,8 +234,8 @@ class RouteExamplePage extends StatelessWidget { @@ -234,8 +234,8 @@ class RouteExamplePage extends StatelessWidget {
234 ), 234 ),
235 ), 235 ),
236 ListTile( 236 ListTile(
237 - title: const Text(  
238 - 'Cupertino Navigator + Scroll + WillPopScope'), 237 + title:
  238 + const Text('Cupertino Navigator + Scroll + PopScope'),
239 onTap: () => Navigator.of(context).push( 239 onTap: () => Navigator.of(context).push(
240 CupertinoSheetRoute<void>( 240 CupertinoSheetRoute<void>(
241 builder: (BuildContext context) => 241 builder: (BuildContext context) =>
@@ -244,7 +244,7 @@ class RouteExamplePage extends StatelessWidget { @@ -244,7 +244,7 @@ class RouteExamplePage extends StatelessWidget {
244 ), 244 ),
245 ), 245 ),
246 ListTile( 246 ListTile(
247 - title: const Text('Modal with WillPopScope'), 247 + title: const Text('Modal with PopScope'),
248 onTap: () => Navigator.of(context).push( 248 onTap: () => Navigator.of(context).push(
249 CupertinoSheetRoute<void>( 249 CupertinoSheetRoute<void>(
250 builder: (BuildContext context) => 250 builder: (BuildContext context) =>
@@ -253,7 +253,7 @@ class RouteExamplePage extends StatelessWidget { @@ -253,7 +253,7 @@ class RouteExamplePage extends StatelessWidget {
253 ), 253 ),
254 ), 254 ),
255 ListTile( 255 ListTile(
256 - title: const Text('Modal Fit with WillPopScope'), 256 + title: const Text('Modal Fit with PopScope'),
257 onTap: () => Navigator.of(context).push( 257 onTap: () => Navigator.of(context).push(
258 CupertinoSheetRoute<void>( 258 CupertinoSheetRoute<void>(
259 fit: SheetFit.loose, 259 fit: SheetFit.loose,
@@ -37,10 +37,10 @@ packages: @@ -37,10 +37,10 @@ packages:
37 dependency: "direct main" 37 dependency: "direct main"
38 description: 38 description:
39 name: collection 39 name: collection
40 - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 40 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
41 url: "https://pub.dev" 41 url: "https://pub.dev"
42 source: hosted 42 source: hosted
43 - version: "1.17.2" 43 + version: "1.18.0"
44 cupertino_icons: 44 cupertino_icons:
45 dependency: "direct main" 45 dependency: "direct main"
46 description: 46 description:
@@ -88,6 +88,30 @@ packages: @@ -88,6 +88,30 @@ packages:
88 url: "https://pub.dev" 88 url: "https://pub.dev"
89 source: hosted 89 source: hosted
90 version: "12.1.0" 90 version: "12.1.0"
  91 + leak_tracker:
  92 + dependency: transitive
  93 + description:
  94 + name: leak_tracker
  95 + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
  96 + url: "https://pub.dev"
  97 + source: hosted
  98 + version: "10.0.0"
  99 + leak_tracker_flutter_testing:
  100 + dependency: transitive
  101 + description:
  102 + name: leak_tracker_flutter_testing
  103 + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
  104 + url: "https://pub.dev"
  105 + source: hosted
  106 + version: "2.0.1"
  107 + leak_tracker_testing:
  108 + dependency: transitive
  109 + description:
  110 + name: leak_tracker_testing
  111 + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
  112 + url: "https://pub.dev"
  113 + source: hosted
  114 + version: "2.0.1"
91 lints: 115 lints:
92 dependency: "direct dev" 116 dependency: "direct dev"
93 description: 117 description:
@@ -108,26 +132,26 @@ packages: @@ -108,26 +132,26 @@ packages:
108 dependency: transitive 132 dependency: transitive
109 description: 133 description:
110 name: matcher 134 name: matcher
111 - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" 135 + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
112 url: "https://pub.dev" 136 url: "https://pub.dev"
113 source: hosted 137 source: hosted
114 - version: "0.12.16" 138 + version: "0.12.16+1"
115 material_color_utilities: 139 material_color_utilities:
116 dependency: transitive 140 dependency: transitive
117 description: 141 description:
118 name: material_color_utilities 142 name: material_color_utilities
119 - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" 143 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
120 url: "https://pub.dev" 144 url: "https://pub.dev"
121 source: hosted 145 source: hosted
122 - version: "0.5.0" 146 + version: "0.8.0"
123 meta: 147 meta:
124 dependency: transitive 148 dependency: transitive
125 description: 149 description:
126 name: meta 150 name: meta
127 - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 151 + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
128 url: "https://pub.dev" 152 url: "https://pub.dev"
129 source: hosted 153 source: hosted
130 - version: "1.9.1" 154 + version: "1.11.0"
131 nested: 155 nested:
132 dependency: transitive 156 dependency: transitive
133 description: 157 description:
@@ -140,10 +164,10 @@ packages: @@ -140,10 +164,10 @@ packages:
140 dependency: transitive 164 dependency: transitive
141 description: 165 description:
142 name: path 166 name: path
143 - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 167 + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
144 url: "https://pub.dev" 168 url: "https://pub.dev"
145 source: hosted 169 source: hosted
146 - version: "1.8.3" 170 + version: "1.9.0"
147 provider: 171 provider:
148 dependency: "direct main" 172 dependency: "direct main"
149 description: 173 description:
@@ -158,7 +182,7 @@ packages: @@ -158,7 +182,7 @@ packages:
158 path: ".." 182 path: ".."
159 relative: true 183 relative: true
160 source: path 184 source: path
161 - version: "1.0.0-pre" 185 + version: "1.0.0"
162 sky_engine: 186 sky_engine:
163 dependency: transitive 187 dependency: transitive
164 description: flutter 188 description: flutter
@@ -176,18 +200,18 @@ packages: @@ -176,18 +200,18 @@ packages:
176 dependency: transitive 200 dependency: transitive
177 description: 201 description:
178 name: stack_trace 202 name: stack_trace
179 - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 203 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
180 url: "https://pub.dev" 204 url: "https://pub.dev"
181 source: hosted 205 source: hosted
182 - version: "1.11.0" 206 + version: "1.11.1"
183 stream_channel: 207 stream_channel:
184 dependency: transitive 208 dependency: transitive
185 description: 209 description:
186 name: stream_channel 210 name: stream_channel
187 - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" 211 + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
188 url: "https://pub.dev" 212 url: "https://pub.dev"
189 source: hosted 213 source: hosted
190 - version: "2.1.1" 214 + version: "2.1.2"
191 string_scanner: 215 string_scanner:
192 dependency: transitive 216 dependency: transitive
193 description: 217 description:
@@ -208,10 +232,10 @@ packages: @@ -208,10 +232,10 @@ packages:
208 dependency: transitive 232 dependency: transitive
209 description: 233 description:
210 name: test_api 234 name: test_api
211 - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" 235 + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
212 url: "https://pub.dev" 236 url: "https://pub.dev"
213 source: hosted 237 source: hosted
214 - version: "0.6.0" 238 + version: "0.6.1"
215 vector_math: 239 vector_math:
216 dependency: transitive 240 dependency: transitive
217 description: 241 description:
@@ -220,14 +244,14 @@ packages: @@ -220,14 +244,14 @@ packages:
220 url: "https://pub.dev" 244 url: "https://pub.dev"
221 source: hosted 245 source: hosted
222 version: "2.1.4" 246 version: "2.1.4"
223 - web: 247 + vm_service:
224 dependency: transitive 248 dependency: transitive
225 description: 249 description:
226 - name: web  
227 - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 250 + name: vm_service
  251 + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
228 url: "https://pub.dev" 252 url: "https://pub.dev"
229 source: hosted 253 source: hosted
230 - version: "0.1.4-beta" 254 + version: "13.0.0"
231 sdks: 255 sdks:
232 - dart: ">=3.1.0-185.0.dev <4.0.0" 256 + dart: ">=3.3.0 <4.0.0"
233 flutter: ">=3.7.0" 257 flutter: ">=3.7.0"
@@ -4,7 +4,7 @@ publish_to: 'none' @@ -4,7 +4,7 @@ publish_to: 'none'
4 version: 1.0.0+1 4 version: 1.0.0+1
5 5
6 environment: 6 environment:
7 - sdk: ">=3.19.0 <4.0.0" 7 + sdk: ">=3.3.0 <4.0.0"
8 8
9 dependencies: 9 dependencies:
10 flutter: 10 flutter:
@@ -182,7 +182,8 @@ class SheetRoute<T> extends PageRoute<T> with DelegatedTransitionsRoute<T> { @@ -182,7 +182,8 @@ class SheetRoute<T> extends PageRoute<T> with DelegatedTransitionsRoute<T> {
182 @protected 182 @protected
183 bool shouldPreventPopForExtent(double extent) { 183 bool shouldPreventPopForExtent(double extent) {
184 return extent < willPopThreshold && 184 return extent < willPopThreshold &&
185 - hasScopedWillPopCallback && 185 + (hasScopedWillPopCallback ||
  186 + popDisposition == RoutePopDisposition.doNotPop) &&
186 controller!.velocity <= 0; 187 controller!.velocity <= 0;
187 } 188 }
188 189
@@ -466,20 +467,24 @@ class __SheetRouteContainerState extends State<_SheetRouteContainer> @@ -466,20 +467,24 @@ class __SheetRouteContainerState extends State<_SheetRouteContainer>
466 duration: const Duration(milliseconds: 400), 467 duration: const Duration(milliseconds: 400),
467 curve: Curves.easeInOut, 468 curve: Curves.easeInOut,
468 ); 469 );
469 -  
470 - route.willPop().then(  
471 - (RoutePopDisposition disposition) {  
472 - if (disposition == RoutePopDisposition.pop) {  
473 - _sheetController.relativeAnimateTo(  
474 - 0,  
475 - duration: const Duration(milliseconds: 400),  
476 - curve: Curves.easeInOut,  
477 - );  
478 - } else {  
479 - _sheetController.position.stopPreventingDrag();  
480 - }  
481 - },  
482 - ); 470 + if (route.popDisposition == RoutePopDisposition.doNotPop) {
  471 + _sheetController.position.stopPreventingDrag();
  472 + route.onPopInvoked(false);
  473 + } else {
  474 + route.willPop().then(
  475 + (RoutePopDisposition disposition) {
  476 + if (disposition == RoutePopDisposition.pop) {
  477 + _sheetController.relativeAnimateTo(
  478 + 0,
  479 + duration: const Duration(milliseconds: 400),
  480 + curve: Curves.easeInOut,
  481 + );
  482 + } else {
  483 + _sheetController.position.stopPreventingDrag();
  484 + }
  485 + },
  486 + );
  487 + }
483 } 488 }
484 489
485 @override 490 @override