widgetWithText method

Finder widgetWithText(
  1. Type widgetType,
  2. String text,
  3. {bool skipOffstage = true}

Looks for widgets that contain a Text descendant with text in it.

Sample code

// Suppose there is a button with text 'Update' in it:
const Button(
  child: Text('Update')

// It can be found and tapped like this:
tester.tap(find.widgetWithText(Button, 'Update'));

If the skipOffstage argument is true (the default), then this skips nodes that are Offstage or that are from inactive Routes.


Finder widgetWithText(Type widgetType, String text, { bool skipOffstage = true }) {
  return find.ancestor(
    of: find.text(text, skipOffstage: skipOffstage),
    matching: find.byType(widgetType, skipOffstage: skipOffstage),