scrollToIndex method
Future<bool>
scrollToIndex(
- int index, {
- bool animate = true,
- Duration duration = const Duration(milliseconds: 300),
- Curve curve = Curves.easeInOut,
- double alignment = 0.0,
- EdgeInsets padding = EdgeInsets.zero,
- BuildContext? sliverContext,
- bool isFixedHeight = false,
Scrolls to make the item at index visible, using animation if animate is true.
This is a convenience method that calls either animateToIndex or jumpToIndex
based on the animate parameter.
Example:
await cubit.scrollToIndex(10, animate: true);
cubit.scrollToIndex(0, animate: false);
Implementation
Future<bool> scrollToIndex(
int index, {
bool animate = true,
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.easeInOut,
double alignment = 0.0,
EdgeInsets padding = EdgeInsets.zero,
BuildContext? sliverContext,
bool isFixedHeight = false,
}) async {
if (animate) {
return animateToIndex(
index,
duration: duration,
curve: curve,
alignment: alignment,
padding: padding,
sliverContext: sliverContext,
isFixedHeight: isFixedHeight,
);
} else {
return jumpToIndex(
index,
alignment: alignment,
padding: padding,
sliverContext: sliverContext,
isFixedHeight: isFixedHeight,
);
}
}