getObjList<T> static method

List<T>? getObjList<T>(
  1. String? source,
  2. T f(
    1. Map v
    )
)

Converts JSON string list source to object list.

Implementation

static List<T>? getObjList<T>(String? source, T f(Map v)) {
  if (source == null || source.isEmpty) return null;
  try {
    List list = json.decode(source);
    return list.map((value) {
      if (value is String) {
        value = json.decode(value);
      }
      return f(value);
    }).toList();
  } catch (e) {
    print('JsonUtil convert error, Exception:${e.toString()}');
  }
  return null;
}