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
CodePudding user response:
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]