I have a settings screen where the user can select 1 of 5 possible images which are laid out in a horizontal listview. The images are too wide for the screen so the listview scrolls horizontally.
I am going for a 'lazy susan' effect where if you keep scrolling left, it just infinitely scrolls through the same 5 options (A B C D E A B C D E A B C...)
Is it possible to setup infinite scrolling on a finite list?
I've spent ages researching but infinite scrolling only seems to be a concept when pulling from the web or generating content programatically and i just want to infinitely scroll through my 5 items...
CodePudding user response:
You can but it takes some workaround, which I had to do but it became ugly very fast. Easiest way is to use the carousel slider package. https://pub.dev/packages/carousel_slider
CodePudding user response:
Just use ListView.builder
with a builder callback returns the same items in a loop. For example:
ListView.builder(
itemBuilder: (buildContext, index) {
return listOfWidgets[index % listOfWidgets.length];
},
),