List 선언시 생성됨 Iterable 사용시 생성됨

void main(){
  final numbers = List.generate(6, (index){
    print('the number ${index + 1} generated');
    return index + 1;
  });
 
 
  for(final number in numbers.take(2)){
    print('the number $number is used');
  }
 
  print('---------------------------------------');
 
  final values = Iterable.generate(6, (index){
    print('The iterable number ${index + 1} generated');
    return index + 1;
  });
 
  for(final number in values.take(2)){
    print('Then iterable number $number is used');
  }
}
 
// Output will look like this
// the number 1 is generated
// the number 2 is generated
// the number 3 is generated
// the number 4 is generated
// the number 5 is generated
// the number 6 is generated
// the number 1 is used
// the number 2 is used
// ---------------------------------------
// The iterable number 1 generated
// The iterable number 1 is used
// The iterable number 2 generated
// The iterable number 2 is used
// Output will look like this
// the number 1 is generated
// the number 2 is generated
// the number 3 is generated
// the number 4 is generated
// the number 5 is generated
// the number 6 is generated
// the number 1 is used
// the number 2 is used
// ---------------------------------------
// The iterable number 1 generated
// The iterable number 1 is used
// The iterable number 2 generated
// The iterable number 2 is used
 

참고