element<T extends Element> method

T element<T extends Element>(
  1. FinderBase<Element> 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>(finders.FinderBase<Element> finder) {
  TestAsyncUtils.guardSync();
  return finder.evaluate().single as T;
}