format exported json

Make the exported applications' file more readable in case it is needed to be opened with a text editor.
This commit is contained in:
Giannis Lagodimos
2024-09-22 22:50:17 +03:00
parent 5be2c9b51d
commit f3481f94dd

View File

@@ -1598,12 +1598,13 @@ class AppsProvider with ChangeNotifier {
} }
String? returnPath; String? returnPath;
if (!pickOnly) { if (!pickOnly) {
var encoder = const JsonEncoder.withIndent(" ");
Map<String, dynamic> finalExport = generateExportJSON(); Map<String, dynamic> finalExport = generateExportJSON();
var result = await saf.createFile(exportDir, var result = await saf.createFile(exportDir,
displayName: displayName:
'${tr('obtainiumExportHyphenatedLowercase')}-${DateTime.now().toIso8601String().replaceAll(':', '-')}${isAuto ? '-auto' : ''}.json', '${tr('obtainiumExportHyphenatedLowercase')}-${DateTime.now().toIso8601String().replaceAll(':', '-')}${isAuto ? '-auto' : ''}.json',
mimeType: 'application/json', mimeType: 'application/json',
bytes: Uint8List.fromList(utf8.encode(jsonEncode(finalExport)))); bytes: Uint8List.fromList(utf8.encode(encoder.convert(finalExport))));
if (result == null) { if (result == null) {
throw ObtainiumError(tr('unexpectedError')); throw ObtainiumError(tr('unexpectedError'));
} }