jsonDecodeAsList<T extends Object> function

List<T> jsonDecodeAsList<T extends Object>(
  1. String json, [
  2. List<T> defaultValue = const []
])

json decoding.

Only lists are output. If it is not a list, null is output.

If Json cannot be converted, defaultValue will be returned.

Implementation

List<T> jsonDecodeAsList<T extends Object>(String json,
    [List<T> defaultValue = const []]) {
  try {
    return (jsonDecode(json) as List).cast<T>();
    // ignore: empty_catches
  } catch (e) {}
  return defaultValue;
}