Insert element at the beginning of the list in dart
Use
List.insert(index, value);
Use insert()
method of List
to add the item, here the index would be 0
to add it in the beginning. Example:
List<String> list = ["B", "C", "D"];
list.insert(0, "A"); // at index 0 we are adding A
// list now becomes ["A", "B", "C", "D"]