Unverified Commit c71978f6 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Remove deprecated DefaultFocusTraversal widget (#51240)

Remove deprecated DefaultFocusTraversal widget
parent 69080e07
......@@ -1713,87 +1713,6 @@ class _FocusTraversalGroupMarker extends InheritedWidget {
bool updateShouldNotify(InheritedWidget oldWidget) => false;
}
/// A deprecated widget that describes the inherited focus policy for focus
/// traversal for its descendants.
///
/// _This widget has been deprecated: use [FocusTraversalGroup] instead._
@Deprecated(
'Use FocusTraversalGroup as a replacement for DefaultFocusTraversal. Be aware that FocusTraversalGroup does add an (unfocusable) Focus widget to the hierarchy that DefaultFocusTraversal does not. Use FocusTraversalGroup.of(context) as a replacement for DefaultFocusTraversal.of(context). '
'This feature was deprecated after v1.14.3.'
)
class DefaultFocusTraversal extends InheritedWidget {
/// Creates a [DefaultFocusTraversal] object.
///
/// The [child] argument must not be null.
const DefaultFocusTraversal({
Key key,
this.policy,
@required Widget child,
}) : super(key: key, child: child);
/// The policy used to move the focus from one focus node to another when
/// traversing them using a keyboard.
///
/// _This widget has been deprecated: use [FocusTraversalGroup] instead._
///
/// If not specified, traverses in reading order using
/// [ReadingOrderTraversalPolicy].
///
/// See also:
///
/// * [FocusTraversalPolicy] for the API used to impose traversal order
/// policy.
/// * [WidgetOrderTraversalPolicy] for a traversal policy that traverses
/// nodes in the order they are added to the widget tree.
/// * [ReadingOrderTraversalPolicy] for a traversal policy that traverses
/// nodes in the reading order defined in the widget tree, and then top to
/// bottom.
final FocusTraversalPolicy policy;
/// Returns the [FocusTraversalPolicy] that most tightly encloses the given
/// [BuildContext].
///
/// _This method has been deprecated: use `FocusTraversalGroup.of(context)` instead._
///
/// It does not create a rebuild dependency because changing the traversal
/// order doesn't change the widget tree, so nothing needs to be rebuilt as a
/// result of an order change.
///
/// The [context] argument must not be null.
static FocusTraversalPolicy of(BuildContext context, {bool nullOk = false}) {
final DefaultFocusTraversal inherited = context.getElementForInheritedWidgetOfExactType<DefaultFocusTraversal>()?.widget as DefaultFocusTraversal;
assert(() {
if (nullOk) {
return true;
}
if (context == null) {
throw FlutterError(
'The context given to DefaultFocusTraversal.of was null, so '
'consequently no FocusTraversalGroup ancestor can be found.',
);
}
if (inherited == null) {
throw FlutterError(
'Unable to find a DefaultFocusTraversal widget in the context.\n'
'DefaultFocusTraversal.of() was called with a context that does not contain a '
'DefaultFocusTraversal.\n'
'No DefaultFocusTraversal ancestor could be found starting from the context that was '
'passed to DefaultFocusTraversal.of(). This can happen because there is not a '
'WidgetsApp or MaterialApp widget (those widgets introduce a DefaultFocusTraversal), '
'or it can happen if the context comes from a widget above those widgets.\n'
'The context used was:\n'
' $context',
);
}
return true;
}());
return inherited?.policy ?? ReadingOrderTraversalPolicy();
}
@override
bool updateShouldNotify(DefaultFocusTraversal oldWidget) => false;
}
// A base class for all of the default actions that request focus for a node.
class _RequestFocusActionBase extends Action {
_RequestFocusActionBase(LocalKey name) : super(name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment