scrollToIndexIfNotVisible method
Scrolls to the given index only if the item is not visible already.
index is the target index of the item.
itemHeight is the height of a single item.
Implementation
Future<void> scrollToIndexIfNotVisible(
int index,
double itemHeight, {
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.easeInOut,
}) {
if (!isItemVisible(index, itemHeight)) {
return scrollToIndex(index, itemHeight, duration: duration, curve: curve);
}
return Future.value();
}