convertToListString method
Implementation
List<String> convertToListString() {
//if the String is only "[]" or empty, return an empty list
if (this == '[]' || isEmpty) {
return [];
}
//first check if the String is a valid list format
if (!startsWith('[') || !endsWith(']')) {
throw FormatException(
'StringExtensions.convertToListString() | String is not in a valid list format: $this');
}
//otherwise, remove the first and last characters (the "[" and "]" characters)
//and split the String by the ", " characters
//and return the list of Strings
return substring(1, length - 1).split(', ');
}