widgetWithText method

Finder widgetWithText (Type widgetType, String text, { bool skipOffstage: true })

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

Sample code

// Suppose you have a button with text 'Update' in it:
new Button(
  child: new Text('Update')
)

// You can find and tap on it 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.

Implementation

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