@@ -342,15 +342,27 @@ class SemanticsFlag {
342342 static const int _kIsCheckStateMixedIndex = 1 << 25 ;
343343 static const int _kHasExpandedStateIndex = 1 << 26 ;
344344 static const int _kIsExpandedIndex = 1 << 27 ;
345- // READ THIS: if you add a flag here, you MUST update the numSemanticsFlags
346- // value in testing/dart/semantics_test.dart and
347- // lib/web_ui/test/engine/semantics/semantics_api_test.dart, or tests will
348- // fail. Also, please update the Flag enum in
349- // flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java,
350- // and the SemanticsFlag class in lib/web_ui/lib/semantics.dart. If the new flag
351- // affects the visibility of a [SemanticsNode] to accessibility services,
352- // `flutter_test/controller.dart#SemanticsController._importantFlags`
353- // must be updated as well.
345+ static const int _kHasSelectedStateIndex = 1 << 28 ;
346+ // READ THIS: if you add a flag here, you MUST update the following:
347+ //
348+ // - Add an appropriately named and documented `static const SemanticsFlag`
349+ // field to this class.
350+ // - Add the new flag to `_kFlagById` in this file.
351+ // - Make changes in lib/web_ui/lib/semantics.dart in the web engine that mirror
352+ // the changes in this file (i.e. `_k*Index`, `static const SemanticsFlag`,
353+ // `_kFlagById`).
354+ // - Increment the `numSemanticsFlags` value in testing/dart/semantics_test.dart
355+ // and in lib/web_ui/test/engine/semantics/semantics_api_test.dart.
356+ // - Add the new flag to platform-specific enums:
357+ // - The `Flag` enum in flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java.
358+ // - The `SemanticsFlags` enum in lib/ui/semantics/semantics_node.h.
359+ // - The `FlutterSemanticsFlag` enum in shell/platform/embedder/embedder.h.
360+ // - If the new flag affects the visibility of a [SemanticsNode] to accessibility services,
361+ // update `flutter_test/controller.dart#SemanticsController._importantFlags`
362+ // accordingly.
363+ // - If the new flag affects focusability of a semantics node, also update the
364+ // value of `AccessibilityBridge.FOCUSABLE_FLAGS` in
365+ // flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java.
354366
355367 /// The semantics node has the quality of either being "checked" or "unchecked".
356368 ///
@@ -386,9 +398,20 @@ class SemanticsFlag {
386398 /// Must be false when the checkbox is either checked or unchecked.
387399 static const SemanticsFlag isCheckStateMixed = SemanticsFlag ._(_kIsCheckStateMixedIndex, 'isCheckStateMixed' );
388400
401+ /// The semantics node has the quality of either being "selected" or "unselected".
402+ ///
403+ /// Whether the widget corresponding to this node is currently selected or not
404+ /// is determined by the [isSelected] flag.
405+ ///
406+ /// When this flag is not set, the corresponding widget cannot be selected by
407+ /// the user, and the presence or the lack of [isSelected] does not carry any
408+ /// meaning.
409+ static const SemanticsFlag hasSelectedState = SemanticsFlag ._(_kHasSelectedStateIndex, 'hasSelectedState' );
389410
390411 /// Whether a semantics node is selected.
391412 ///
413+ /// This flag only has meaning in nodes that have [hasSelectedState] flag set.
414+ ///
392415 /// If true, the semantics node is "selected". If false, the semantics node is
393416 /// "unselected".
394417 ///
@@ -614,6 +637,7 @@ class SemanticsFlag {
614637 static const Map <int , SemanticsFlag > _kFlagById = < int , SemanticsFlag > {
615638 _kHasCheckedStateIndex: hasCheckedState,
616639 _kIsCheckedIndex: isChecked,
640+ _kHasSelectedStateIndex: hasSelectedState,
617641 _kIsSelectedIndex: isSelected,
618642 _kIsButtonIndex: isButton,
619643 _kIsTextFieldIndex: isTextField,
0 commit comments