spotText function

  1. @useResult
WidgetSelector<AnyText> spotText(
  1. Pattern text, {
  2. List<WidgetSelector<Widget>> parents = const [],
  3. List<WidgetSelector<Widget>> children = const [],
  4. bool exact = false,
})

Finds text on the screen

spotText compares text using 'contains'. For more control over the comparison, use spotTextWhere or set exact to true.

This method combines finding of Text, EditableText and SelectableText widgets. Ultimately, all widgets show text as RichText widget.

For assertions against specific text widgets and their properties, use the normal spot method and set the text widget type as generic type argument.

final welcome = spot<Text>().whereText((it) => it.equals("Hello"));
welcome.first().snapshot().hasMaxLines(1).hasTextAlign(TextAlign.center);

Implementation

@useResult
WidgetSelector<AnyText> spotText(
  Pattern text, {
  List<WidgetSelector> parents = const [],
  List<WidgetSelector> children = const [],
  bool exact = false,
}) {
  return _global.spotText(
    text,
    parents: parents,
    children: children,
    exact: exact,
  );
}