revealInScrollViews function

void revealInScrollViews(
  1. RenderObject target, {
  2. RenderObject? surrounding,
})

Reveals a laid-out target through enclosing scroll viewports.

Call after layout. When surrounding fits, include it as well (for example, a control's label and validation message). Otherwise prioritize the target, aligning an oversized target's start. Does not change focus or reveal children hidden by presentation policy.

Implementation

void revealInScrollViews(RenderObject target, {RenderObject? surrounding}) {
  final plan = _revealPlan(target, surrounding: surrounding);
  if (plan == null) return;
  for (final entry in plan.entries) {
    entry.key.scrollContentBy(entry.value);
  }
}