onIndexChanged property
final
A callback invoked when the leading item changes.
The leading item is the first visible item in the carousel view.
The callback fires only when the leading item is completely out of view, whether due to user interaction or programmatic scrolling. If the leading item remains partially visible, the leading index will not change and the callback will not be invoked.
Example:
CarouselView(
itemExtent: 200.0,
onIndexChanged: (int index) {
print('Leading item changed to: $index');
},
children: <Widget>[
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.blue),
],
)
Implementation
final ValueChanged<int>? onIndexChanged;