toJsonString method

String toJsonString()

Returns a JSON string representation of the BaseModel.

Implementation

String toJsonString() {
  try {
    final encoder = const JsonEncoder.withIndent('  ');
    return encoder.convert(sortedJson());
  } catch (e) {
    try {
      return '{"e": "$e"}';
    } catch (e) {
      return '{"e": "An error occurred but could not be converted to JSON!"}';
    }
  }
}