Manually control the carousel with CarouselSliderController
masterTo programmatically control the carousel (e.g., via buttons), create an instance of CarouselSliderController and pass it to the carouselController property of the CarouselSlider widget.
class CarouselDemo extends StatelessWidget {
CarouselSliderController buttonCarouselController = CarouselSliderController();
@override
Widget build(BuildContext context) => Column(
children: <Widget>[
CarouselSlider(
items: child,
carouselController: buttonCarouselController,
options: CarouselOptions(
autoPlay: false,
enlargeCenterPage: true,
viewportFraction: 0.9,
aspectRatio: 2.0,
initialPage: 2,
),
),
RaisedButton(
onPressed: () => buttonCarouselController.nextPage(
duration: Duration(milliseconds: 300), curve: Curves.linear),
child: Text('→'),
)
]
);
}