tryJsonDecodeList static method

List<String>? tryJsonDecodeList(
  1. String? value
)

Attempts to decode a JSON string to a list of strings.

Implementation

static List<String>? tryJsonDecodeList(String? value) {
  if (value == null || !isJson(value)) return null;
  try {
    final dynamic data = dc.json.decode(value);
    if (data is! List || data.isEmpty) return null;
    if (!data.every((dynamic e) => e is String)) return null;
    return List<String>.from(data);
  } on FormatException {
    return null;
  }
}