Mutable List & Immutable List

Mutable List & Immutable List

A mutable List means they can change after the declaration, and an immutable List means they can’t change after the declaration.

Example

void main() {
  List<String> names = ["Raj", "Jeel", "Rocky"]; // Mutable List
  names[1] = "Jeet"; // possible
  names[2] = "Kevin"; // possible

  print(names[0]);
  print(names[1]);
  print(names[2]);

  const List<String> names1 = ["Darshan", "bhalu", "Meet"]; // Immutable List
 // cooment to be 
 // names1[1] = "Milan"; // not possible
 // names1[2] = "Kevin"; // not possible

  print(names1);
  print(names1[1]);
  print(names1[2]);
}

Output

Raj
Jeet
Kevin
[Darshan, bhalu, Meet]
bhalu
Meet

Exited.