tryJsonDecodeList static method
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 Object catch (e, stackTrace) {
// ignore: avoid_print_error - debugPrint is appropriate for utility packages (stripped in release builds, no external dependencies)
debugPrint('JsonUtils.tryJsonDecodeList failed: $e\n$stackTrace');
return null;
}
}