toIntList property

List<int> toIntList

Converts a comma-separated string into a List

Example:

print('1,2,3'.toIntList); // Output: [1, 2, 3]
print('1,a,3'.toIntList); // Output: [1, 3]

Implementation

List<int> get toIntList => split(',').map((s) => int.tryParse(s)).where((i) => i != null).cast<int>().toList();