animateToItem method
Animates to a specific item index within the list
Implementation
Future<void> animateToItem(int itemIndex, {
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.ease,
}) async {
if (!isAttached || _isDisposed) return;
try {
// This is a simplified version - in a real implementation,
// you'd calculate the actual item offset based on item heights
await _scrollController!.animateTo(
itemIndex * 60.0, // Assuming average item height of 60
duration: duration,
curve: curve,
);
} catch (e, stackTrace) {
_callbacks?.onError?.call('Failed to animate to item $itemIndex in list $_listIndex: $e', stackTrace);
}
}