firstWidget<T extends Widget> method

T firstWidget<T extends Widget>(
  1. FinderBase<Element> finder
)

The first matching widget according to a depth-first pre-order traversal of the widget tree.

Throws a StateError if finder is empty.

  • Use widget if you only expect to match one widget.

Implementation

T firstWidget<T extends Widget>(finders.FinderBase<Element> finder) {
  TestAsyncUtils.guardSync();
  return finder.evaluate().first.widget as T;
}