Newbie here, i need help with a short list.generate question

Hi everyone, i recently started learning flutter and dart, so my apologies if this is a really simple problem, i am trying to generate a list with values from another list, as follows:

List transactions = List.generate(15, (index)=>{
“name”: names[1],
“dp”: “assets/cm1.jpeg”,
});

but i want the numbers 1 to increase by 1 with every new entry. so the list should be outputting the names in my names list 1 by 1 and cm1.jpeg, cm2.jpeg etc. similar to the i+1 code.

Thanks in advance!

Hi and welcome.
You can use the generator’s index with string interpolation, i.e.

List transactions = List.generate(15, (index) => {
  'name': names[index],
  'dp': "assets/cm${index+1}.jpeg"
});

in ${index+1}, +1 is because index starts from 0.

hth