Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can i make items repeat again if i arrive the end of list

i have the following

  ListView.builder(
   controller: controller,
   itemCount: 50, 
   itemBuilder: (BuildContext context, int index) { 
   return Text('hello world');
   },
    )

now when i scroll to last index it stop scroll anymore .. but how can i force it to keep scroll with same items that i passed through like following

1
2
3
4
etc .. 50

keep scroll 
1
2
3
4
etc .. 50

and so

what i am doing now is adding others same 50 items but it not good idea

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

how could i make it auto repeat without End . without to add

>Solution :

Simply leave out the itemCount and in the itemBuilder you could modulo 50 the index to have them repeat every 50. For example:

ListView.builder(
  controller: controller,
  itemBuilder: (BuildContext context, int index) {
    index = index % 50;
    return Text('hello world $index');
  },
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading