firstWidget<T extends Widget> method Null safety

T firstWidget<T extends Widget>(
  1. Finder 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>(Finder finder) {
  TestAsyncUtils.guardSync();
  return finder.evaluate().first.widget as T;
}