tryJsonDecodeListMap static method
Attempts to decode a JSON string to a list of maps.
Implementation
static List<Map<String, dynamic>>? tryJsonDecodeListMap(String? value) {
if (value == null || !isJson(value)) return null;
try {
final dynamic data = dc.json.decode(value);
if (data is! List || data.isEmpty || data[0] is! Map<String, dynamic>) return null;
if (!data.every((dynamic e) => e is Map<String, dynamic>)) return null;
return List<Map<String, dynamic>>.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.tryJsonDecodeListMap failed: $e\n$stackTrace');
return null;
}
}