fix WillPop issue
Fix issue that moved the bottom sheet after will pop returns false
Showing
1 changed file
with
11 additions
and
1 deletions
| @@ -149,11 +149,17 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | @@ -149,11 +149,17 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | ||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void _cancelClose() { | 151 | void _cancelClose() { |
| 152 | - widget.animationController.forward(); | 152 | + widget.animationController.forward().then((value) { |
| 153 | + // When using WillPop, animation doesn't end at 1. | ||
| 154 | + // Check more in detail the problem | ||
| 155 | + if (!widget.animationController.isCompleted) | ||
| 156 | + widget.animationController.value = 1; | ||
| 157 | + }); | ||
| 153 | _bounceDragController.reverse(); | 158 | _bounceDragController.reverse(); |
| 154 | } | 159 | } |
| 155 | 160 | ||
| 156 | bool _isCheckingShouldClose = false; | 161 | bool _isCheckingShouldClose = false; |
| 162 | + | ||
| 157 | FutureOr<bool> shouldClose() async { | 163 | FutureOr<bool> shouldClose() async { |
| 158 | if (_isCheckingShouldClose) return false; | 164 | if (_isCheckingShouldClose) return false; |
| 159 | if (widget.shouldClose == null) return null; | 165 | if (widget.shouldClose == null) return null; |
| @@ -178,6 +184,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | @@ -178,6 +184,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | ||
| 178 | _close(); | 184 | _close(); |
| 179 | print('close'); | 185 | print('close'); |
| 180 | return; | 186 | return; |
| 187 | + } else { | ||
| 188 | + _cancelClose(); | ||
| 181 | } | 189 | } |
| 182 | } | 190 | } |
| 183 | 191 | ||
| @@ -218,6 +226,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | @@ -218,6 +226,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | ||
| 218 | } else { | 226 | } else { |
| 219 | _cancelClose(); | 227 | _cancelClose(); |
| 220 | } | 228 | } |
| 229 | + } else { | ||
| 230 | + _cancelClose(); | ||
| 221 | } | 231 | } |
| 222 | } | 232 | } |
| 223 | 233 |
-
Please register or login to post a comment