tryFromJson static method

String? tryFromJson(
  1. Object? data, {
  2. String? indent,
  3. bool toStringEncodable = false,
})

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}) {
  try {
    return fromJson(data!,
        indent: indent, toStringEncodable: toStringEncodable);
  } catch (e) {
    return null;
  }
}