ensureVisible method
Future<void>
ensureVisible(
- RenderObject object, {
- double alignment = 0.0,
- Duration duration = Duration.zero,
- Curve curve = Curves.ease,
- ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,
- RenderObject? targetRenderObject,
override
Animates the position such that the given object is as visible as possible by just scrolling this position.
The optional targetRenderObject
parameter is used to determine which area
of that object should be as visible as possible. If targetRenderObject
is null, the entire RenderObject (as defined by its
RenderObject.paintBounds) will be as visible as possible. If
targetRenderObject
is provided, it must be a descendant of the object.
See also:
- ScrollPositionAlignmentPolicy for the way in which
alignment
is applied, and the way the givenobject
is aligned.
Implementation
@override
Future<void> ensureVisible(
RenderObject object, {
double alignment = 0.0,
Duration duration = Duration.zero,
Curve curve = Curves.ease,
ScrollPositionAlignmentPolicy alignmentPolicy =
ScrollPositionAlignmentPolicy.explicit,
RenderObject? targetRenderObject,
}) {
// Since the _PagePosition is intended to cover the available space within
// its viewport, stop trying to move the target render object to the center
// - otherwise, could end up changing which page is visible and moving the
// targetRenderObject out of the viewport.
return super.ensureVisible(
object,
alignment: alignment,
duration: duration,
curve: curve,
alignmentPolicy: alignmentPolicy,
targetRenderObject: null,
);
}