getList<T> static method

List<T>? getList<T>(
  1. dynamic source
)

get List 1, 2, 3, 4, 5, 6; "\"tom\",\"tony\",\"jacky\"";

Implementation

static List<T>? getList<T>(dynamic source) {
  List? list;
  if (source is String) {
    list = json.decode(source);
  } else {
    list = source;
  }
  return list?.map((v) {
    return v as T;
  }).toList();
}