tryFromJson static method
String?
tryFromJson(
- Object? data, {
- String? indent,
- bool toStringEncodable = false,
- Object? toEncodable(
- dynamic
- JsonEncodeOptions? options,
Converts a Dart object represented as a Map to a JSON-encoded string if possible.
The input data is a Map representing the Dart object.
Implementation
static String? tryFromJson(
Object? data, {
String? indent,
bool toStringEncodable = false,
Object? Function(dynamic)? toEncodable,
JsonEncodeOptions? options,
}) {
if (data == null) return null;
try {
return fromJson(
data,
indent: indent,
toStringEncodable: toStringEncodable,
toEncodable: toEncodable,
options: options,
);
} catch (e) {
return null;
}
}