Jaime Blasco

fix/will_pop_closure

... ... @@ -45,7 +45,7 @@ class ModalBottomSheet extends StatefulWidget {
required this.expanded,
required this.onClosing,
required this.child,
}) : super(key: key);
}) : super(key: key);
/// The closeProgressThreshold parameter
/// specifies when the bottom sheet will be dismissed when user drags it.
... ... @@ -224,24 +224,27 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
// ignore: unawaited_futures
_bounceDragController.reverse();
var canClose = true;
if (widget.shouldClose != null) {
_cancelClose();
canClose = await shouldClose();
}
if (canClose) {
// If speed is bigger than _minFlingVelocity try to close it
if (velocity > _minFlingVelocity) {
_close();
} else if (hasReachedCloseThreshold) {
if (widget.animationController.value > 0.0) {
// ignore: unawaited_futures
widget.animationController.fling(velocity: -1.0);
Future<void> tryClose() async {
if (widget.shouldClose != null) {
_cancelClose();
bool canClose = await shouldClose();
if (canClose) {
_close();
}
_close();
} else {
_cancelClose();
_close();
}
}
// If speed is bigger than _minFlingVelocity try to close it
if (velocity > _minFlingVelocity) {
tryClose();
} else if (hasReachedCloseThreshold) {
if (widget.animationController.value > 0.0) {
// ignore: unawaited_futures
widget.animationController.fling(velocity: -1.0);
}
tryClose();
} else {
_cancelClose();
}
... ...