toList property

List toList

Attempts to decode the string as a List

Example:

print('["a", "b", "c"]'.toList); // Output: [a, b, c]
print('abc'.toList); // Output: []

Implementation

List<dynamic> get toList {
  try {
    return json.decode(this) as List<dynamic>;
  } catch (e) {
    return [];
  }
}