Reputation: 527
I want to start carousel slider from a specific index. My carousel slider widget takes a props
object which has below properties:
class Props {
List<String> strings;
int index;
Props({
required this.index,
required this.strings,
});
}
And my carousel slider is as:
return CarouselSlider(
options: CarouselOptions(
...
),
carouselController: controller,
items: widget.props.strings.map(
(item) {
..some widget
},
).toList(),
);
Everything is all good except I want to start the carousel from widget.props.index
. So rather than starting from index 0 of List<String>
I can start from index 2 or 3.
Upvotes: 0
Views: 436
Reputation: 5726
You could set the initialPage
field by setting the options
.
CarouselSlider(
// ...
options: CarouselOptions(
initialPage: 2,
),
),
Upvotes: 1