firstElement<T extends Element> method

T firstElement<T extends Element>(
  1. FinderBase<Element> finder

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

Throws a StateError if finder is empty.

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


T firstElement<T extends Element>(finders.FinderBase<Element> finder) {
  return finder.evaluate().first as T;