widget<T extends Widget> method

T widget <T extends Widget>(Finder finder)

The matching widget in the widget tree.

Throws a StateError if finder is empty or matches more than one widget.

  • Use firstWidget if you expect to match several widgets but only want the first.
  • Use widgetList if you expect to match several widgets and want all of them.

Implementation

T widget<T extends Widget>(Finder finder) {
  TestAsyncUtils.guardSync();
  return finder.evaluate().single.widget as T;
}