renderObject<T extends RenderObject> method Null safety

T renderObject<T extends RenderObject>(
  1. Finder finder
)

The render object of the matching widget in the widget tree.

Throws a StateError if finder is empty or matches more than one widget (even if they all have the same render object).

  • Use firstRenderObject if you expect to match several render objects but only want the first.
  • Use renderObjectList if you expect to match several render objects and want all of them.

Implementation

T renderObject<T extends RenderObject>(Finder finder) {
  TestAsyncUtils.guardSync();
  return finder.evaluate().single.renderObject! as T;
}