Skip to content

Commit 638a944

Browse files
authored
Fix doc warnings for focus code (flutter#62602)
1 parent 87dbfa8 commit 638a944

File tree

4 files changed

+84
-80
lines changed

4 files changed

+84
-80
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ class EditableText extends StatefulWidget {
975975
/// {@tool dartpad --template=stateful_widget_material}
976976
/// When a non-completion action is pressed, such as "next" or "previous", it
977977
/// is often desirable to move the focus to the next or previous field. To do
978-
/// this, handle it as in this example, by calling [FocusNode.focusNext] in
978+
/// this, handle it as in this example, by calling [FocusNode.nextFocus] in
979979
/// the `onFieldSubmitted` callback of [TextFormField]. ([TextFormField] wraps
980980
/// [EditableText] internally, and uses the value of `onFieldSubmitted` as its
981981
/// [onSubmitted]).

packages/flutter/lib/src/widgets/focus_manager.dart

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ enum UnfocusDisposition {
196196
/// receive a notification when the focus changes. If the [Focus] and
197197
/// [FocusScope] widgets are being used to manage the nodes, consider
198198
/// establishing an [InheritedWidget] dependency on them by calling [Focus.of]
199-
/// or [FocusScope.of] instead. [Focus.hasFocus] can also be used to establish a
200-
/// similar dependency, especially if all that is needed is to determine whether
201-
/// or not the widget is focused at build time.
199+
/// or [FocusScope.of] instead. [FocusNode.hasFocus] can also be used to
200+
/// establish a similar dependency, especially if all that is needed is to
201+
/// determine whether or not the widget is focused at build time.
202202
///
203203
/// To see the focus tree in the debug console, call [debugDumpFocusTree]. To
204204
/// get the focus tree as a string, call [debugDescribeFocusTree].
@@ -224,12 +224,12 @@ enum UnfocusDisposition {
224224
/// [FocusAttachment] object. This attachment is created by calling [attach],
225225
/// usually from the [State.initState] method. If the hosting widget is updated
226226
/// to have a different focus node, then the updated node needs to be attached
227-
/// in [State.didUpdateWidget], after calling [detach] on the previous
228-
/// [FocusAttachment].
227+
/// in [State.didUpdateWidget], after calling [FocusAttachment.detach] on the
228+
/// previous [FocusAttachment].
229229
///
230-
/// Because [FocusNode]s form a sparse representation of the widget tree,
231-
/// they must be updated whenever the widget tree is rebuilt. This is done by
232-
/// calling [FocusAttachment.reparent], usually from the [State.build] or
230+
/// Because [FocusNode]s form a sparse representation of the widget tree, they
231+
/// must be updated whenever the widget tree is rebuilt. This is done by calling
232+
/// [FocusAttachment.reparent], usually from the [State.build] or
233233
/// [State.didChangeDependencies] methods of the widget that represents the
234234
/// focused region, so that the [BuildContext] assigned to the [FocusScopeNode]
235235
/// can be tracked (the context is used to obtain the [RenderObject], from which
@@ -241,9 +241,9 @@ enum UnfocusDisposition {
241241
///
242242
/// If, as is common, the hosting [StatefulWidget] is also the owner of the
243243
/// focus node, then it will also call [dispose] from its [State.dispose] (in
244-
/// which case the [detach] may be skipped, since dispose will automatically
245-
/// detach). If another object owns the focus node, then it must call [dispose]
246-
/// when the node is done being used.
244+
/// which case the [FocusAttachment.detach] may be skipped, since dispose will
245+
/// automatically detach). If another object owns the focus node, then it must
246+
/// call [dispose] when the node is done being used.
247247
/// {@endtemplate}
248248
///
249249
/// {@template flutter.widgets.focus_manager.focus.keyEvents}
@@ -284,10 +284,10 @@ enum UnfocusDisposition {
284284
/// [DirectionalFocusTraversalPolicyMixin], but custom policies can be built
285285
/// based upon these policies. See [FocusTraversalPolicy] for more information.
286286
///
287-
/// {@tool dartpad --template=stateless_widget_scaffold}
288-
/// This example shows how a FocusNode should be managed if not using the
289-
/// [Focus] or [FocusScope] widgets. See the [Focus] widget for a similar
290-
/// example using [Focus] and [FocusScope] widgets.
287+
/// {@tool dartpad --template=stateless_widget_scaffold} This example shows how
288+
/// a FocusNode should be managed if not using the [Focus] or [FocusScope]
289+
/// widgets. See the [Focus] widget for a similar example using [Focus] and
290+
/// [FocusScope] widgets.
291291
///
292292
/// ```dart imports
293293
/// import 'package:flutter/services.dart';
@@ -396,14 +396,14 @@ enum UnfocusDisposition {
396396
///
397397
/// See also:
398398
///
399-
/// * [Focus], a widget that manages a [FocusNode] and provides access to
400-
/// focus information and actions to its descendant widgets.
401-
/// * [FocusTraversalGroup], a widget used to group together and configure the
402-
/// focus traversal policy for a widget subtree.
403-
/// * [FocusManager], a singleton that manages the primary focus and
404-
/// distributes key events to focused nodes.
405-
/// * [FocusTraversalPolicy], a class used to determine how to move the focus
406-
/// to other nodes.
399+
/// * [Focus], a widget that manages a [FocusNode] and provides access to focus
400+
/// information and actions to its descendant widgets.
401+
/// * [FocusTraversalGroup], a widget used to group together and configure the
402+
/// focus traversal policy for a widget subtree.
403+
/// * [FocusManager], a singleton that manages the primary focus and distributes
404+
/// key events to focused nodes.
405+
/// * [FocusTraversalPolicy], a class used to determine how to move the focus to
406+
/// other nodes.
407407
class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
408408
/// Creates a focus node.
409409
///
@@ -1039,10 +1039,10 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
10391039
/// will add the [node] as a child of this node before requesting focus.
10401040
///
10411041
/// If the given [node] is a [FocusScopeNode] and that focus scope node has a
1042-
/// non-null [focusedChild], then request the focus for the focused child.
1043-
/// This process is recursive and continues until it encounters either a focus
1044-
/// scope node with a null focused child or an ordinary (non-scope)
1045-
/// [FocusNode] is found.
1042+
/// non-null [FocusScopeNode.focusedChild], then request the focus for the
1043+
/// focused child. This process is recursive and continues until it encounters
1044+
/// either a focus scope node with a null focused child or an ordinary
1045+
/// (non-scope) [FocusNode] is found.
10461046
///
10471047
/// The node is notified that it has received the primary focus in a
10481048
/// microtask, so notification may lag the request by up to one frame.

packages/flutter/lib/src/widgets/focus_scope.dart

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import 'inherited_notifier.dart';
2929
/// changes, use the [Focus.of] and [FocusScope.of] static methods.
3030
///
3131
/// To access the focused state of the nearest [Focus] widget, use
32-
/// [Focus.hasFocus] from a build method, which also establishes a relationship
32+
/// [FocusNode.hasFocus] from a build method, which also establishes a relationship
3333
/// between the calling widget and the [Focus] widget that will rebuild the
3434
/// calling widget when the focus changes.
3535
///
@@ -364,16 +364,17 @@ class Focus extends StatefulWidget {
364364
/// This is sometimes useful if a [Focus] widget should receive key events as
365365
/// part of the focus chain, but shouldn't be accessible via focus traversal.
366366
///
367-
/// This is different from [canRequestFocus] because it only implies that the
368-
/// widget can't be reached via traversal, not that it can't be focused. It may
369-
/// still be focused explicitly.
367+
/// This is different from [FocusNode.canRequestFocus] because it only implies
368+
/// that the widget can't be reached via traversal, not that it can't be
369+
/// focused. It may still be focused explicitly.
370370
final bool skipTraversal;
371371

372372
/// {@template flutter.widgets.Focus.includeSemantics}
373373
/// Include semantics information in this widget.
374374
///
375-
/// If true, this widget will include a [Semantics] node that
376-
/// indicates the [Semantics.focusable] and [Semantics.focused] properties.
375+
/// If true, this widget will include a [Semantics] node that indicates the
376+
/// [SemanticsProperties.focusable] and [SemanticsProperties.focused]
377+
/// properties.
377378
///
378379
/// It is not typical to set this to false, as that can affect the semantics
379380
/// information available to accessibility systems.
@@ -386,45 +387,46 @@ class Focus extends StatefulWidget {
386387
/// If true, this widget may request the primary focus.
387388
///
388389
/// Defaults to true. Set to false if you want the [FocusNode] this widget
389-
/// manages to do nothing when [requestFocus] is called on it. Does not affect
390-
/// the children of this node, and [FocusNode.hasFocus] can still return true
391-
/// if this node is the ancestor of the primary focus.
390+
/// manages to do nothing when [FocusNode.requestFocus] is called on it. Does
391+
/// not affect the children of this node, and [FocusNode.hasFocus] can still
392+
/// return true if this node is the ancestor of the primary focus.
392393
///
393-
/// This is different than [skipTraversal] because [skipTraversal] still
394-
/// allows the widget to be focused, just not traversed to.
394+
/// This is different than [Focus.skipTraversal] because [Focus.skipTraversal]
395+
/// still allows the widget to be focused, just not traversed to.
395396
///
396-
/// Setting [canRequestFocus] to false implies that the widget will also be
397-
/// skipped for traversal purposes.
397+
/// Setting [FocusNode.canRequestFocus] to false implies that the widget will
398+
/// also be skipped for traversal purposes.
398399
///
399400
/// See also:
400401
///
401-
/// * [FocusTraversalGroup], a widget that sets the traversal policy for
402-
/// its descendants.
403-
/// * [FocusTraversalPolicy], a class that can be extended to describe a
404-
/// traversal policy.
402+
/// * [FocusTraversalGroup], a widget that sets the traversal policy for its
403+
/// descendants.
404+
/// * [FocusTraversalPolicy], a class that can be extended to describe a
405+
/// traversal policy.
405406
/// {@endtemplate}
406407
final bool canRequestFocus;
407408

408409
/// {@template flutter.widgets.Focus.descendantsAreFocusable}
409410
/// If false, will make this widget's descendants unfocusable.
410411
///
411412
/// Defaults to true. Does not affect focusability of this node (just its
412-
/// descendants): for that, use [canRequestFocus].
413+
/// descendants): for that, use [FocusNode.canRequestFocus].
413414
///
414415
/// If any descendants are focused when this is set to false, they will be
415416
/// unfocused. When `descendantsAreFocusable` is set to true again, they will
416417
/// not be refocused, although they will be able to accept focus again.
417418
///
418-
/// Does not affect the value of [canRequestFocus] on the descendants.
419+
/// Does not affect the value of [FocusNode.canRequestFocus] on the
420+
/// descendants.
419421
///
420422
/// See also:
421423
///
422-
/// * [ExcludeFocus], a widget that uses this property to conditionally
423-
/// exclude focus for a subtree.
424-
/// * [FocusTraversalGroup], a widget used to group together and configure
425-
/// the focus traversal policy for a widget subtree that has a
426-
/// `descendantsAreFocusable` parameter to conditionally block focus for a
427-
/// subtree.
424+
/// * [ExcludeFocus], a widget that uses this property to conditionally
425+
/// exclude focus for a subtree.
426+
/// * [FocusTraversalGroup], a widget used to group together and configure the
427+
/// focus traversal policy for a widget subtree that has a
428+
/// `descendantsAreFocusable` parameter to conditionally block focus for a
429+
/// subtree.
428430
/// {@endtemplate}
429431
final bool descendantsAreFocusable;
430432

@@ -870,7 +872,7 @@ class FocusScope extends Focus {
870872
///
871873
/// The [child] argument is required and must not be null.
872874
///
873-
/// The [autofocus], and [showDecorations] arguments must not be null.
875+
/// The [autofocus] argument must not be null.
874876
const FocusScope({
875877
Key key,
876878
FocusScopeNode node,
@@ -979,16 +981,17 @@ class ExcludeFocus extends StatelessWidget {
979981
/// unfocused. When `excluding` is set to false again, they will not be
980982
/// refocused, although they will be able to accept focus again.
981983
///
982-
/// Does not affect the value of [canRequestFocus] on the descendants.
984+
/// Does not affect the value of [FocusNode.canRequestFocus] on the
985+
/// descendants.
983986
///
984987
/// See also:
985988
///
986-
/// * [Focus.descendantsAreFocusable], the attribute of a [Focus] widget that
987-
/// controls this same property for focus widgets.
988-
/// * [FocusTraversalGroup], a widget used to group together and configure
989-
/// the focus traversal policy for a widget subtree that has a
990-
/// `descendantsAreFocusable` parameter to conditionally block focus for a
991-
/// subtree.
989+
/// * [Focus.descendantsAreFocusable], the attribute of a [Focus] widget that
990+
/// controls this same property for focus widgets.
991+
/// * [FocusTraversalGroup], a widget used to group together and configure the
992+
/// focus traversal policy for a widget subtree that has a
993+
/// `descendantsAreFocusable` parameter to conditionally block focus for a
994+
/// subtree.
992995
final bool excluding;
993996

994997
/// The child widget of this [ExcludeFocus].

packages/flutter/lib/src/widgets/focus_traversal.dart

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class _FocusTraversalGroupInfo {
6464
/// A direction along either the horizontal or vertical axes.
6565
///
6666
/// This is used by the [DirectionalFocusTraversalPolicyMixin], and
67-
/// [Focus.focusInDirection] to indicate which direction to look in for the next
68-
/// focus.
67+
/// [FocusNode.focusInDirection] to indicate which direction to look in for the
68+
/// next focus.
6969
enum TraversalDirection {
7070
/// Indicates a direction above the currently focused widget.
7171
up,
@@ -433,7 +433,7 @@ class _DirectionalPolicyData {
433433
///
434434
/// Since hysteresis in the navigation order is undesirable, this implementation
435435
/// maintains a stack of previous locations that have been visited on the
436-
/// [policyData] for the affected [FocusScopeNode]. If the previous direction
436+
/// policy data for the affected [FocusScopeNode]. If the previous direction
437437
/// was the opposite of the current direction, then the this policy will request
438438
/// focus on the previously focused node. Change to another direction other than
439439
/// the current one or its opposite will clear the stack.
@@ -682,7 +682,7 @@ mixin DirectionalFocusTraversalPolicyMixin on FocusTraversalPolicy {
682682
/// Returns true if it successfully found a node and requested focus.
683683
///
684684
/// Maintains a stack of previous locations that have been visited on the
685-
/// [policyData] for the affected [FocusScopeNode]. If the previous direction
685+
/// policy data for the affected [FocusScopeNode]. If the previous direction
686686
/// was the opposite of the current direction, then the this policy will
687687
/// request focus on the previously focused node. Change to another direction
688688
/// other than the current one or its opposite will clear the stack.
@@ -1122,25 +1122,26 @@ class ReadingOrderTraversalPolicy extends FocusTraversalPolicy with DirectionalF
11221122
///
11231123
/// {@template flutter.widgets.focusorder.comparable}
11241124
/// Only orders of the same type are comparable. If a set of widgets in the same
1125-
/// [FocusTraversalGroup] contains orders that are not comparable with each other, it
1126-
/// will assert, since the ordering between such keys is undefined. To avoid
1127-
/// collisions, use a [FocusTraversalGroup] to group similarly ordered widgets
1128-
/// together.
1129-
///
1130-
/// When overriding, [doCompare] must be overridden instead of [compareTo],
1131-
/// which calls [doCompare] to do the actual comparison.
1125+
/// [FocusTraversalGroup] contains orders that are not comparable with each
1126+
/// other, it will assert, since the ordering between such keys is undefined. To
1127+
/// avoid collisions, use a [FocusTraversalGroup] to group similarly ordered
1128+
/// widgets together.
1129+
///
1130+
/// When overriding, [FocusOrder.doCompare] must be overridden instead of
1131+
/// [FocusOrder.compareTo], which calls [FocusOrder.doCompare] to do the actual
1132+
/// comparison.
11321133
/// {@endtemplate}
11331134
///
11341135
/// See also:
11351136
///
1136-
/// * [FocusTraversalGroup], a widget that groups together and imposes a
1137-
/// traversal policy on the [Focus] nodes below it in the widget hierarchy.
1138-
/// * [FocusTraversalOrder], a widget that assigns an order to a widget subtree
1139-
/// for the [OrderedTraversalPolicy] to use.
1140-
/// * [NumericFocusOrder], for a focus order that describes its order with a
1141-
/// `double`.
1142-
/// * [LexicalFocusOrder], a focus order that assigns a string-based lexical
1143-
/// traversal order to a [FocusTraversalOrder] widget.
1137+
/// * [FocusTraversalGroup], a widget that groups together and imposes a
1138+
/// traversal policy on the [Focus] nodes below it in the widget hierarchy.
1139+
/// * [FocusTraversalOrder], a widget that assigns an order to a widget subtree
1140+
/// for the [OrderedTraversalPolicy] to use.
1141+
/// * [NumericFocusOrder], for a focus order that describes its order with a
1142+
/// `double`.
1143+
/// * [LexicalFocusOrder], a focus order that assigns a string-based lexical
1144+
/// traversal order to a [FocusTraversalOrder] widget.
11441145
@immutable
11451146
abstract class FocusOrder with Diagnosticable implements Comparable<FocusOrder> {
11461147
/// Abstract const constructor. This constructor enables subclasses to provide

0 commit comments

Comments
 (0)