toJsonString method

String toJsonString({
  1. bool pretty = true,
})

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());
}