Dart Programming - Updating the Index



Dart allows modifying the value of an item in a List. In other words, one can re-write the value of list item. The following example illustrates the same −

void main() { 
   List l = [1, 2, 3]; 
   l[0] = 123; 
   print(l); 
}

The above example updates the value of the List item with index 0. The output of the code will be −

[123, 2, 3]
dart_programming_lists_basic_operations.htm
Advertisements