protect the hasScopedWillPopCallback ModalRoute method (#7832)

This commit is contained in:
Hans Muller
2017-02-02 15:27:39 -08:00
committed by GitHub
parent cedc74503a
commit e366c9691f

View File

@@ -702,6 +702,17 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
_scopeKey.currentState.removeWillPopCallback(callback);
}
/// True if one or more [WillPopCallback] callbacks exist.
///
/// This method is used to disable the horizontal swipe pop gesture
/// supported by [MaterialPageRoute] for [TargetPlatform.iOS].
/// If a pop might be vetoed, then the back gesture is disabled.
///
/// See also:
///
/// * [addScopedWillPopCallback], which adds a callback.
/// * [removeScopedWillPopCallback], which removes a callback.
@protected
bool get hasScopedWillPopCallback {
return _scopeKey.currentState == null || _scopeKey.currentState.willPopCallbacks.length > 0;
}