I have a PageView to navigate between images that I would like to behave as an infinite loop or as a ring array, that is to say, be able to navigate from the last page to the first one without passing through the ones in the middle.
PageView.builder(
controller: _pageController,
itemCount: 3,
itemBuilder: (context, index) {
return Image.asset(
"assets/images/home_screen/device_content$index.png",
height: 500,
fit: BoxFit.fill,
key: ValueKey<int>(index),
);
},
),
This is the button where I change the page:
IconButton(
onPressed: () {
setState(() {
_n += 1;
if (_n > 2) _n = 0;
_pageController.animateToPage(
_n,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
});
},
icon: const Icon(Icons.arrow_forward_ios),
),
Here is a video of the behaviour
Is there a way to make the animation between the last page and the first one be on the same direction than the animation in between the middle pages?