convertStringIntoStringList function

List<String> convertStringIntoStringList(
  1. String string
)

Implementation

List<String> convertStringIntoStringList(String string) {
  List<String> stringList = [];

  //stringList.length <= 2 means the String is only "[]"
  //or empty or has 1 character (meaning definitely not a list of String which would have minimum 2 characters for an empty list [])
  //therefore return an empty list
  //Furthermore, because the String received from the database
  //is of format "[string1, string2, ...]"
  //therefore when converting it, omit the first and last characters
  //(eg. the "[" and "]" characters of the String)
  //furthermore, each date is separated by the folowing two characters ", "
  stringList = string.length <= 2
      ? []
      : string.substring(1, string.length - 1).split(', ');

  return stringList;
}