containsSemantics function

Matcher containsSemantics(
  1. {String? label,
  2. AttributedString? attributedLabel,
  3. String? hint,
  4. AttributedString? attributedHint,
  5. String? value,
  6. AttributedString? attributedValue,
  7. String? increasedValue,
  8. AttributedString? attributedIncreasedValue,
  9. String? decreasedValue,
  10. AttributedString? attributedDecreasedValue,
  11. String? tooltip,
  12. TextDirection? textDirection,
  13. Rect? rect,
  14. Size? size,
  15. double? elevation,
  16. double? thickness,
  17. int? platformViewId,
  18. int? maxValueLength,
  19. int? currentValueLength,
  20. bool? hasCheckedState,
  21. bool? isChecked,
  22. bool? isCheckStateMixed,
  23. bool? isSelected,
  24. bool? isButton,
  25. bool? isSlider,
  26. bool? isKeyboardKey,
  27. bool? isLink,
  28. bool? isFocused,
  29. bool? isFocusable,
  30. bool? isTextField,
  31. bool? isReadOnly,
  32. bool? hasEnabledState,
  33. bool? isEnabled,
  34. bool? isInMutuallyExclusiveGroup,
  35. bool? isHeader,
  36. bool? isObscured,
  37. bool? isMultiline,
  38. bool? namesRoute,
  39. bool? scopesRoute,
  40. bool? isHidden,
  41. bool? isImage,
  42. bool? isLiveRegion,
  43. bool? hasToggledState,
  44. bool? isToggled,
  45. bool? hasImplicitScrolling,
  46. bool? hasTapAction,
  47. bool? hasLongPressAction,
  48. bool? hasScrollLeftAction,
  49. bool? hasScrollRightAction,
  50. bool? hasScrollUpAction,
  51. bool? hasScrollDownAction,
  52. bool? hasIncreaseAction,
  53. bool? hasDecreaseAction,
  54. bool? hasShowOnScreenAction,
  55. bool? hasMoveCursorForwardByCharacterAction,
  56. bool? hasMoveCursorBackwardByCharacterAction,
  57. bool? hasMoveCursorForwardByWordAction,
  58. bool? hasMoveCursorBackwardByWordAction,
  59. bool? hasSetTextAction,
  60. bool? hasSetSelectionAction,
  61. bool? hasCopyAction,
  62. bool? hasCutAction,
  63. bool? hasPasteAction,
  64. bool? hasDidGainAccessibilityFocusAction,
  65. bool? hasDidLoseAccessibilityFocusAction,
  66. bool? hasDismissAction,
  67. String? onTapHint,
  68. String? onLongPressHint,
  69. List<CustomSemanticsAction>? customActions,
  70. 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 retrieve the semantics data of a widget, use WidgetTester.getSemantics with a Finder that returns a single widget. Semantics must be enabled in order to use this method.

Sample code

final SemanticsHandle handle = tester.ensureSemantics();
expect(tester.getSemantics(find.text('hello')), hasSemantics(label: 'hello'));
handle.dispose();

See also:

Implementation

Matcher containsSemantics({
  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,
  // Flags
  bool? hasCheckedState,
  bool? isChecked,
  bool? isCheckStateMixed,
  bool? isSelected,
  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,
  // Actions
  bool? hasTapAction,
  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(
    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,
    elevation: elevation,
    thickness: thickness,
    platformViewId: platformViewId,
    customActions: customActions,
    maxValueLength: maxValueLength,
    currentValueLength: currentValueLength,
    // Flags
    hasCheckedState: hasCheckedState,
    isChecked: isChecked,
    isCheckStateMixed: isCheckStateMixed,
    isSelected: isSelected,
    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,
    // Actions
    hasTapAction: hasTapAction,
    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,
  );
}