tryEncodeJson static method
Attempts to encode a JSON-serializable json
object into a list of bytes,
returning null if the conversion to JSON string fails.
Implementation
static List<int>? tryEncodeJson(
Object? json, {
String? indent,
bool toStringEncodable = false,
Object? Function(dynamic)? toEncodable,
}) {
if (json == null) return null;
try {
return encodeJson(json,
indent: indent,
toEncodable: toEncodable,
toStringEncodable: toStringEncodable);
} catch (_) {
return null;
}
}