byWidget method Null safety

Finder byWidget(
  1. Widget widget,
  2. {bool skipOffstage = true}
)

Finds widgets whose current widget is the instance given by the argument.

Sample code

// Suppose you have a button created like this:
Widget myButton = Button(
  child: Text('Update')
);

// You can find and tap on it like this:
tester.tap(find.byWidget(myButton));

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

Implementation

Finder byWidget(Widget widget, { bool skipOffstage = true }) => _WidgetFinder(widget, skipOffstage: skipOffstage);