of static method

RenderAbstractViewport of(
  1. RenderObject? object

Returns the RenderAbstractViewport that most tightly encloses the given render object.

If the object does not have a RenderAbstractViewport as an ancestor, this function will assert in debug mode, and throw an exception in release mode.

See also:


static RenderAbstractViewport of(RenderObject? object) {
  final RenderAbstractViewport? viewport = maybeOf(object);
  assert(() {
    if (viewport == null) {
      throw FlutterError(
        'RenderAbstractViewport.of() was called with a render object that was '
        'not a descendant of a RenderAbstractViewport.\n'
        'No RenderAbstractViewport render object ancestor could be found starting '
        'from the object that was passed to RenderAbstractViewport.of().\n'
        'The render object where the viewport search started was:\n'
        '  $object',
    return true;
  return viewport!;