isSemantics function

Matcher isSemantics({
  1. String? identifier,
  2. String? traversalParentIdentifier,
  3. String? traversalChildIdentifier,
  4. String? label,
  5. AttributedString? attributedLabel,
  6. String? hint,
  7. AttributedString? attributedHint,
  8. String? value,
  9. AttributedString? attributedValue,
  10. String? increasedValue,
  11. AttributedString? attributedIncreasedValue,
  12. String? decreasedValue,
  13. AttributedString? attributedDecreasedValue,
  14. String? tooltip,
  15. TextDirection? textDirection,
  16. Rect? rect,
  17. Size? size,
  18. double? elevation,
  19. double? thickness,
  20. int? platformViewId,
  21. int? maxValueLength,
  22. int? currentValueLength,
  23. SemanticsValidationResult? validationResult,
  24. SemanticsInputType? inputType,
  25. String? maxValue,
  26. String? minValue,
  27. bool? hasCheckedState,
  28. bool? isChecked,
  29. bool? isCheckStateMixed,
  30. bool? isSelected,
  31. bool? hasSelectedState,
  32. bool? isButton,
  33. bool? isSlider,
  34. bool? isKeyboardKey,
  35. bool? isLink,
  36. bool? isFocused,
  37. bool? isFocusable,
  38. bool? isTextField,
  39. bool? isReadOnly,
  40. bool? hasEnabledState,
  41. bool? isEnabled,
  42. bool? isInMutuallyExclusiveGroup,
  43. bool? isHeader,
  44. bool? isObscured,
  45. bool? isMultiline,
  46. bool? namesRoute,
  47. bool? scopesRoute,
  48. bool? isHidden,
  49. bool? isImage,
  50. bool? isLiveRegion,
  51. bool? hasToggledState,
  52. bool? isToggled,
  53. bool? hasImplicitScrolling,
  54. bool? hasExpandedState,
  55. bool? isExpanded,
  56. bool? hasRequiredState,
  57. bool? isRequired,
  58. bool? hasTapAction,
  59. bool? hasFocusAction,
  60. bool? hasLongPressAction,
  61. bool? hasScrollLeftAction,
  62. bool? hasScrollRightAction,
  63. bool? hasScrollUpAction,
  64. bool? hasScrollDownAction,
  65. bool? hasIncreaseAction,
  66. bool? hasDecreaseAction,
  67. bool? hasShowOnScreenAction,
  68. bool? hasMoveCursorForwardByCharacterAction,
  69. bool? hasMoveCursorBackwardByCharacterAction,
  70. bool? hasMoveCursorForwardByWordAction,
  71. bool? hasMoveCursorBackwardByWordAction,
  72. bool? hasSetTextAction,
  73. bool? hasSetSelectionAction,
  74. bool? hasCopyAction,
  75. bool? hasCutAction,
  76. bool? hasPasteAction,
  77. bool? hasDidGainAccessibilityFocusAction,
  78. bool? hasDidLoseAccessibilityFocusAction,
  79. bool? hasDismissAction,
  80. String? onTapHint,
  81. String? onLongPressHint,
  82. List<CustomSemanticsAction>? customActions,
  83. List<Matcher>? children,
})

Asserts that a SemanticsNode contains the specified information.

There are no default expected values, so no unspecified values will be validated.

To find a SemanticsNode directly, use CommonFinders.semantics. These methods will search the semantics tree directly and avoid the edge cases that SemanticsController.find sometimes runs into.

To retrieve the semantics data of a widget, use SemanticsController.find with a FinderBase that returns a single widget. Semantics must be enabled in order to use this method.

Sample code

testWidgets('isSemantics', (WidgetTester tester) async {
  final SemanticsHandle handle = tester.ensureSemantics();
  // ...
  expect(tester.getSemantics(find.text('hello')), isSemantics(label: 'hello'));
  handle.dispose();
});

See also:

Implementation

Matcher isSemantics({
  String? identifier,
  String? traversalParentIdentifier,
  String? traversalChildIdentifier,
  String? label,
  AttributedString? attributedLabel,
  String? hint,
  AttributedString? attributedHint,
  String? value,
  AttributedString? attributedValue,
  String? increasedValue,
  AttributedString? attributedIncreasedValue,
  String? decreasedValue,
  AttributedString? attributedDecreasedValue,
  String? tooltip,
  TextDirection? textDirection,
  Rect? rect,
  Size? size,
  double? elevation,
  double? thickness,
  int? platformViewId,
  int? maxValueLength,
  int? currentValueLength,
  SemanticsValidationResult? validationResult,
  ui.SemanticsInputType? inputType,
  String? maxValue,
  String? minValue,
  // Flags
  bool? hasCheckedState,
  bool? isChecked,
  bool? isCheckStateMixed,
  bool? isSelected,
  bool? hasSelectedState,
  bool? isButton,
  bool? isSlider,
  bool? isKeyboardKey,
  bool? isLink,
  bool? isFocused,
  bool? isFocusable,
  bool? isTextField,
  bool? isReadOnly,
  bool? hasEnabledState,
  bool? isEnabled,
  bool? isInMutuallyExclusiveGroup,
  bool? isHeader,
  bool? isObscured,
  bool? isMultiline,
  bool? namesRoute,
  bool? scopesRoute,
  bool? isHidden,
  bool? isImage,
  bool? isLiveRegion,
  bool? hasToggledState,
  bool? isToggled,
  bool? hasImplicitScrolling,
  bool? hasExpandedState,
  bool? isExpanded,
  bool? hasRequiredState,
  bool? isRequired,
  // Actions
  bool? hasTapAction,
  bool? hasFocusAction,
  bool? hasLongPressAction,
  bool? hasScrollLeftAction,
  bool? hasScrollRightAction,
  bool? hasScrollUpAction,
  bool? hasScrollDownAction,
  bool? hasIncreaseAction,
  bool? hasDecreaseAction,
  bool? hasShowOnScreenAction,
  bool? hasMoveCursorForwardByCharacterAction,
  bool? hasMoveCursorBackwardByCharacterAction,
  bool? hasMoveCursorForwardByWordAction,
  bool? hasMoveCursorBackwardByWordAction,
  bool? hasSetTextAction,
  bool? hasSetSelectionAction,
  bool? hasCopyAction,
  bool? hasCutAction,
  bool? hasPasteAction,
  bool? hasDidGainAccessibilityFocusAction,
  bool? hasDidLoseAccessibilityFocusAction,
  bool? hasDismissAction,
  // Custom actions and overrides
  String? onTapHint,
  String? onLongPressHint,
  List<CustomSemanticsAction>? customActions,
  List<Matcher>? children,
}) {
  return _MatchesSemanticsData(
    identifier: identifier,
    traversalChildIdentifier: traversalChildIdentifier,
    traversalParentIdentifier: traversalParentIdentifier,
    label: label,
    attributedLabel: attributedLabel,
    hint: hint,
    attributedHint: attributedHint,
    value: value,
    attributedValue: attributedValue,
    increasedValue: increasedValue,
    attributedIncreasedValue: attributedIncreasedValue,
    decreasedValue: decreasedValue,
    attributedDecreasedValue: attributedDecreasedValue,
    tooltip: tooltip,
    textDirection: textDirection,
    rect: rect,
    size: size,
    platformViewId: platformViewId,
    customActions: customActions,
    maxValueLength: maxValueLength,
    currentValueLength: currentValueLength,
    validationResult: validationResult,
    inputType: inputType,
    minValue: minValue,
    maxValue: maxValue,
    // Flags
    hasCheckedState: hasCheckedState,
    isChecked: isChecked,
    isCheckStateMixed: isCheckStateMixed,
    isSelected: isSelected,
    hasSelectedState: hasSelectedState,
    isButton: isButton,
    isSlider: isSlider,
    isKeyboardKey: isKeyboardKey,
    isLink: isLink,
    isFocused: isFocused,
    isFocusable: isFocusable,
    isTextField: isTextField,
    isReadOnly: isReadOnly,
    hasEnabledState: hasEnabledState,
    isEnabled: isEnabled,
    isInMutuallyExclusiveGroup: isInMutuallyExclusiveGroup,
    isHeader: isHeader,
    isObscured: isObscured,
    isMultiline: isMultiline,
    namesRoute: namesRoute,
    scopesRoute: scopesRoute,
    isHidden: isHidden,
    isImage: isImage,
    isLiveRegion: isLiveRegion,
    hasToggledState: hasToggledState,
    isToggled: isToggled,
    hasImplicitScrolling: hasImplicitScrolling,
    hasExpandedState: hasExpandedState,
    isExpanded: isExpanded,
    hasRequiredState: hasRequiredState,
    isRequired: isRequired,
    // Actions
    hasTapAction: hasTapAction,
    hasFocusAction: hasFocusAction,
    hasLongPressAction: hasLongPressAction,
    hasScrollLeftAction: hasScrollLeftAction,
    hasScrollRightAction: hasScrollRightAction,
    hasScrollUpAction: hasScrollUpAction,
    hasScrollDownAction: hasScrollDownAction,
    hasIncreaseAction: hasIncreaseAction,
    hasDecreaseAction: hasDecreaseAction,
    hasShowOnScreenAction: hasShowOnScreenAction,
    hasMoveCursorForwardByCharacterAction: hasMoveCursorForwardByCharacterAction,
    hasMoveCursorBackwardByCharacterAction: hasMoveCursorBackwardByCharacterAction,
    hasMoveCursorForwardByWordAction: hasMoveCursorForwardByWordAction,
    hasMoveCursorBackwardByWordAction: hasMoveCursorBackwardByWordAction,
    hasSetTextAction: hasSetTextAction,
    hasSetSelectionAction: hasSetSelectionAction,
    hasCopyAction: hasCopyAction,
    hasCutAction: hasCutAction,
    hasPasteAction: hasPasteAction,
    hasDidGainAccessibilityFocusAction: hasDidGainAccessibilityFocusAction,
    hasDidLoseAccessibilityFocusAction: hasDidLoseAccessibilityFocusAction,
    hasDismissAction: hasDismissAction,
    // Custom actions and overrides
    children: children,
    onLongPressHint: onLongPressHint,
    onTapHint: onTapHint,
  );
}