state<T extends State<StatefulWidget>> method

T state<T extends State<StatefulWidget>>(
  1. FinderBase<Element> finder
)

The matching state in the widget tree.

Throws a StateError if finder is empty, matches more than one state, or matches a widget that has no state.

  • Use firstState if you expect to match several states but only want the first.
  • Use stateList if you expect to match several states and want all of them.

Implementation

T state<T extends State>(finders.FinderBase<Element> finder) {
  TestAsyncUtils.guardSync();
  return _stateOf<T>(finder.evaluate().single, finder);
}