From 6826b272aa48a3c6f9b3b689d08acddb702aa370 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 18 Mar 2025 23:04:47 +0100 Subject: [PATCH] Indent xml for saving --- lib/mod_list.dart | 11 +++++++++-- lib/mod_troubleshooter_widget.dart | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/mod_list.dart b/lib/mod_list.dart index 5427aca..6c73fb3 100644 --- a/lib/mod_list.dart +++ b/lib/mod_list.dart @@ -257,8 +257,15 @@ class ModList { // Build the XML document final xmlDocument = builder.buildDocument(); - // Write the XML document to file - file.writeAsStringSync(xmlDocument.toString()); + // Convert to string with 2-space indentation + final prettyXml = xmlDocument.toXmlString( + pretty: true, + indent: ' ', // 2 spaces + newLine: '\n', + ); + + // Write the formatted XML document to file + file.writeAsStringSync(prettyXml); logger.info('Successfully saved mod configuration to: $configPath'); } catch (e) { logger.error('Error saving configuration file: $e'); diff --git a/lib/mod_troubleshooter_widget.dart b/lib/mod_troubleshooter_widget.dart index 8fba710..5a5fcef 100644 --- a/lib/mod_troubleshooter_widget.dart +++ b/lib/mod_troubleshooter_widget.dart @@ -171,9 +171,9 @@ class _ModTroubleshooterWidgetState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - '${_loadOrder.order.length} mods prepared for testing. Please use Save button in the Mods tab to save config.', + '${_loadOrder.order.length} mods have been successfully saved to the configuration.', ), - backgroundColor: Colors.orange, + backgroundColor: Colors.green, duration: const Duration(seconds: 4), ), );