dev feat: pretty print json helper util

This commit is contained in:
julian 2023-05-23 09:36:55 -06:00
parent ee830a4788
commit efd2742184

View file

@ -1,3 +1,5 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
@ -50,4 +52,15 @@ abstract class Util {
}
return MaterialColor(color.value, swatch);
}
static void printJson(dynamic json) {
if (json is Map || json is List) {
final spaces = ' ' * 4;
final encoder = JsonEncoder.withIndent(spaces);
final pretty = encoder.convert(json);
log(pretty);
} else {
log(dynamic.toString());
}
}
}