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

Is it possible to genarrt a list From my assets

I want to creat a List like this

List<String>
imagePaths = ['assets/images/1.jpg', 'assets/images/2.jpg', 'assets/images/3.jpg'];

but in my case I have 90 items (‘assets/images/1.jpg’- ‘assets/images/90.jpg’ is there any way to generate the list for me or do I have to write it down

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

>Solution :

you can create with list generate

List<String> path = List.generate(5,(int idx) => 'assets/images/$idx.jpg');

print (path);
// result :
[assets/images/0.jpg, assets/images/1.jpg, assets/images/2.jpg, assets/images/3.jpg, assets/images/4.jpg]
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