ensureVisible method
Scrolls the scrollables that enclose the given context so as to make the given context visible.
Implementation
static Future<void> ensureVisible(BuildContext context, {
double alignment = 0.0,
Duration duration = Duration.zero,
Curve curve = Curves.ease,
}) {
final List<Future<void>> futures = <Future<void>>[];
ScrollableState scrollable = Scrollable.of(context);
while (scrollable != null) {
futures.add(scrollable.position.ensureVisible(
context.findRenderObject(),
alignment: alignment,
duration: duration,
curve: curve,
));
context = scrollable.context;
scrollable = Scrollable.of(context);
}
if (futures.isEmpty || duration == Duration.zero)
return Future<void>.value();
if (futures.length == 1)
return futures.single;
return Future.wait<void>(futures).then<void>((List<void> _) => null);
}