element<T extends Element> method Null safety

T element<T extends Element>(
  1. Finder finder
)

The matching element in the widget tree.

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

  • Use firstElement if you expect to match several elements but only want the first.
  • Use elementList if you expect to match several elements and want all of them.

Implementation

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