deepCopyList<T> function
Deeply copies list
.
Implementation
List<T>? deepCopyList<T>(List<T>? list) {
if (list == null) return null;
if (list is List<String>) {
return List<String>.from(list) as List<T>;
} else if (list is Uint8List) {
return Uint8List.fromList(list as Uint8List) as List<T>;
} else if (list is Int8List) {
return Int8List.fromList(list as Int8List) as List<T>;
} else if (list is List<int>) {
return List<int>.from(list) as List<T>;
} else if (list is List<double>) {
return List<double>.from(list) as List<T>;
} else if (list is List<num>) {
return List<num>.from(list) as List<T>;
} else if (list is List<bool>) {
return List<bool>.from(list) as List<T>;
}
if (list.isEmpty) return <T>[];
return list.map<T>((T e) => deepCopy(e) as T).toList();
}