myPrintFormattedJson function

String myPrintFormattedJson(
  1. dynamic jsonObject, {
  2. bool doPrint = true,
})

Implementation

String myPrintFormattedJson(dynamic jsonObject, {bool doPrint = true}) {
  var encoder = const JsonEncoder.withIndent('  '); // 两个空格用于缩进
  String prettyPrint = encoder.convert(jsonObject);
  if (doPrint) {
    debugPrint(prettyPrint);
  }
  return prettyPrint;
}