Committed by
GitHub
Merge pull request #250 from jamesblasco/fix/will_pop_close
fix/will_pop_closure
Showing
1 changed file
with
11 additions
and
8 deletions
| @@ -224,24 +224,27 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | @@ -224,24 +224,27 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | ||
| 224 | // ignore: unawaited_futures | 224 | // ignore: unawaited_futures |
| 225 | _bounceDragController.reverse(); | 225 | _bounceDragController.reverse(); |
| 226 | 226 | ||
| 227 | - var canClose = true; | 227 | + Future<void> tryClose() async { |
| 228 | if (widget.shouldClose != null) { | 228 | if (widget.shouldClose != null) { |
| 229 | _cancelClose(); | 229 | _cancelClose(); |
| 230 | - canClose = await shouldClose(); | ||
| 231 | - } | 230 | + bool canClose = await shouldClose(); |
| 232 | if (canClose) { | 231 | if (canClose) { |
| 232 | + _close(); | ||
| 233 | + } | ||
| 234 | + } else { | ||
| 235 | + _close(); | ||
| 236 | + } | ||
| 237 | + } | ||
| 238 | + | ||
| 233 | // If speed is bigger than _minFlingVelocity try to close it | 239 | // If speed is bigger than _minFlingVelocity try to close it |
| 234 | if (velocity > _minFlingVelocity) { | 240 | if (velocity > _minFlingVelocity) { |
| 235 | - _close(); | 241 | + tryClose(); |
| 236 | } else if (hasReachedCloseThreshold) { | 242 | } else if (hasReachedCloseThreshold) { |
| 237 | if (widget.animationController.value > 0.0) { | 243 | if (widget.animationController.value > 0.0) { |
| 238 | // ignore: unawaited_futures | 244 | // ignore: unawaited_futures |
| 239 | widget.animationController.fling(velocity: -1.0); | 245 | widget.animationController.fling(velocity: -1.0); |
| 240 | } | 246 | } |
| 241 | - _close(); | ||
| 242 | - } else { | ||
| 243 | - _cancelClose(); | ||
| 244 | - } | 247 | + tryClose(); |
| 245 | } else { | 248 | } else { |
| 246 | _cancelClose(); | 249 | _cancelClose(); |
| 247 | } | 250 | } |
-
Please register or login to post a comment