deepCopyList function

List deepCopyList(
  1. List source
)

Recursively deep-copies source, cloning any nested maps and lists so the result shares no mutable structure with the original. Scalar values are copied by reference.

Implementation

List<dynamic> deepCopyList(List<dynamic> source) => source.map<dynamic>((dynamic e) {
  if (e is Map<String, dynamic>) return deepCopyMap(e);
  if (e is List<dynamic>) return deepCopyList(e);
  return e;
}).toList();