Pageview
final _controller = PageController(initialPage: 0);
PageView(
controller: _controller,
physics: const NeverScrollableScrollPhysics(),
children: [
Text('1'),
Text('2'),
Text('3'),
Text('4'),
],
),
IconButton(
onPressed: () {
_controller.previousPage(
duration: Duration(milliseconds: 100),
curve: Curves.easeInOut,
);
},
icon: const Icon(
Icons.arrow_back,
size: 50,
),
),
Pageview Builder
final _controller = PageController(initialPage: 0);
List<int> data = [11, 22, 33, 44, 55, 66];
PageView(
controller: _controller,
itemCount: data.length,
itemBuilder: (context, index) {
return Text("${data[index]}");
}
),
IconButton(
onPressed: () {
_controller.previousPage(
duration: Duration(milliseconds: 100),
curve: Curves.easeInOut,
);
},
icon: const Icon(
Icons.arrow_back,
size: 50,
),
),
IconButton(
onPressed: () {
_controller.animateToPage(
_controller.page!.toInt() + 1,
duration: Duration(milliseconds: 100),
curve: Curves.easeInOut,
);
},
icon: const Icon(
Icons.arrow_forward,
size: 50,
),
),