toJsonString method
Pretty-printed by default — the common case is a checked-in baseline file or CI log output, where readability matters more than size.
Implementation
String toJsonString({bool pretty = true}) {
final encoder = pretty
? const JsonEncoder.withIndent(' ')
: const JsonEncoder();
return encoder.convert(toJson());
}