toScrollKey static method
Future<void>
toScrollKey(
- GlobalKey<
State< key, {StatefulWidget> > - double alignment = 0.5,
- Duration duration = Durations.long4,
Implementation
static Future<void> toScrollKey(
GlobalKey key, {
double alignment = 0.5,
Duration duration = Durations.long4,
}) async {
final context = key.currentContext;
if (context == null) return;
final renderObject = context.findRenderObject();
if (renderObject == null) return;
final scrollable = Scrollable.maybeOf(context);
if (scrollable == null) return;
await Future.delayed(duration);
await scrollable.position.ensureVisible(
renderObject,
duration: Durations.medium1,
curve: Curves.easeInOut,
alignment: alignment,
);
}