Skip to content

Commit

Permalink
Add 2 space indent to settings json
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Sep 18, 2024
1 parent ec98372 commit 4228132
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/services/files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class FilesService extends Service {
/// from the file should be done with [Settings.fromJson].
File get settingsFile => outputDir / "settings.json";

/// The encoder to convert a Map<> to a json string with a nice indent
final JsonEncoder jsonEncoder = const JsonEncoder.withIndent(" ");

/// Ensure that files and directories that are expected to be present actually
/// exist on the system. If not, create them.
@override
Expand All @@ -63,7 +66,7 @@ class FilesService extends Service {

/// Saves the [Settings] object to the [settingsFile], as JSON.
Future<void> writeSettings(Settings? value) async {
final json = jsonEncode(value?.toJson() ?? {});
final json = jsonEncoder.convert(value?.toJson() ?? {});
await settingsFile.writeAsString(json);
}

Expand Down

0 comments on commit 4228132

Please sign in to comment.