How to display more than one page with PageView?
You can control how many pages are displayed in a PageView through a PageController
var controller = PageController(viewportFraction: 1 / 3);
Then pass it to your PageView:
PageView(
controller: controller,
...
),
You have to use LayoutBuilder to check the max width and then you can set the PageController(viewportFraction: );
accordingly.
Here is an example:
PageController pageController;
@override
Widget build(BuildContext context) {
return Scaffold(
body: LayoutBuilder(builder: (context, constrains) {
if (constrains.maxWidth < 600) {
pageController = PageController(viewportFraction: 1.0);
} else {
pageController = PageController(viewportFraction: 0.3);
}
return PageView.builder(
controller: pageController,
itemCount: places.length,
itemBuilder: (context, index) {
// return your view for pageview
},
);
}),
);
}