scrollToGlobalKey method
Future<bool>
scrollToGlobalKey({
- required GlobalKey<
State< globalKey,StatefulWidget> > - double alignment = 0.0,
- Duration duration = Durations.short4,
- Curve curve = Curves.easeOut,
- ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,
Implementation
Future<bool> scrollToGlobalKey({
required GlobalKey globalKey,
double alignment = 0.0,
Duration duration = Durations.short4,
Curve curve = Curves.easeOut,
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,
}) async {
final BuildContext? context = globalKey.currentContext;
if (context == null) {
return false;
}
await Scrollable.ensureVisible(
context,
alignment: alignment,
duration: duration,
curve: curve,
alignmentPolicy: alignmentPolicy,
);
return true;
}