showOnScreen method

  1. @override
void showOnScreen(
  1. {RenderObject? descendant,
  2. Rect? rect,
  3. Duration duration =,
  4. Curve curve = Curves.ease}

Attempt to make (a portion of) this or a descendant RenderObject visible on screen.

If descendant is provided, that RenderObject is made visible. If descendant is omitted, this RenderObject is made visible.

The optional rect parameter describes which area of that RenderObject should be shown on screen. If rect is null, the entire RenderObject (as defined by its paintBounds) will be revealed. The rect parameter is interpreted relative to the coordinate system of descendant if that argument is provided and relative to this RenderObject otherwise.

The duration parameter can be set to a non-zero value to bring the target object on screen in an animation defined by curve.

See also:


void showOnScreen({
  RenderObject? descendant,
  Rect? rect,
  Duration duration =,
  Curve curve = Curves.ease,
}) {
  // It is possible for one and not both axes to allow for implicit scrolling,
  // so handling is split between the options for allowed implicit scrolling.
  final bool allowHorizontal = horizontalOffset.allowImplicitScrolling;
  final bool allowVertical = verticalOffset.allowImplicitScrolling;
  AxisDirection? axisDirection;
  switch ((allowHorizontal, allowVertical)) {
    case (true, true):
      // Both allow implicit scrolling.
    case (false, true):
      // Only the vertical Axis allows implicit scrolling.
      axisDirection = verticalAxisDirection;
    case (true, false):
      // Only the horizontal Axis allows implicit scrolling.
      axisDirection = horizontalAxisDirection;
    case (false, false):
      // Neither axis allows for implicit scrolling.
      return super.showOnScreen(
        descendant: descendant,
        rect: rect,
        duration: duration,
        curve: curve,

  final Rect? newRect = RenderTwoDimensionalViewport.showInViewport(
    descendant: descendant,
    viewport: this,
    axisDirection: axisDirection,
    rect: rect,
    duration: duration,
    curve: curve,

    rect: newRect,
    duration: duration,
    curve: curve,