Committed by
GitHub
Merge pull request #250 from jamesblasco/fix/will_pop_close
fix/will_pop_closure
Showing
1 changed file
with
18 additions
and
15 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; | ||
228 | - if (widget.shouldClose != null) { | ||
229 | - _cancelClose(); | ||
230 | - canClose = await shouldClose(); | ||
231 | - } | ||
232 | - if (canClose) { | ||
233 | - // If speed is bigger than _minFlingVelocity try to close it | ||
234 | - if (velocity > _minFlingVelocity) { | ||
235 | - _close(); | ||
236 | - } else if (hasReachedCloseThreshold) { | ||
237 | - if (widget.animationController.value > 0.0) { | ||
238 | - // ignore: unawaited_futures | ||
239 | - widget.animationController.fling(velocity: -1.0); | 227 | + Future<void> tryClose() async { |
228 | + if (widget.shouldClose != null) { | ||
229 | + _cancelClose(); | ||
230 | + bool canClose = await shouldClose(); | ||
231 | + if (canClose) { | ||
232 | + _close(); | ||
240 | } | 233 | } |
241 | - _close(); | ||
242 | } else { | 234 | } else { |
243 | - _cancelClose(); | 235 | + _close(); |
236 | + } | ||
237 | + } | ||
238 | + | ||
239 | + // If speed is bigger than _minFlingVelocity try to close it | ||
240 | + if (velocity > _minFlingVelocity) { | ||
241 | + tryClose(); | ||
242 | + } else if (hasReachedCloseThreshold) { | ||
243 | + if (widget.animationController.value > 0.0) { | ||
244 | + // ignore: unawaited_futures | ||
245 | + widget.animationController.fling(velocity: -1.0); | ||
244 | } | 246 | } |
247 | + tryClose(); | ||
245 | } else { | 248 | } else { |
246 | _cancelClose(); | 249 | _cancelClose(); |
247 | } | 250 | } |
-
Please register or login to post a comment