From d4d45aa69be286bd37d2fa9e6135e6450c5c7a0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Moritz=20H=C3=B6lting?=
<87192362+moritz-hoelting@users.noreply.github.com>
Date: Mon, 26 Jan 2026 17:47:44 +0100
Subject: [PATCH 1/3] fix adding newlines in web/index.html every run
rather than removing and adding elements (including whitespace), replacing the element if it exists does not add newlines
---
lib/cli_commands.dart | 1 +
lib/templates.dart | 11 ++--
lib/web.dart | 122 +++++++++++++++++++++++++++---------------
3 files changed, 86 insertions(+), 48 deletions(-)
mode change 100644 => 100755 lib/cli_commands.dart
mode change 100644 => 100755 lib/templates.dart
mode change 100644 => 100755 lib/web.dart
diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart
old mode 100644
new mode 100755
index 1779ef1..0e58ee5
--- a/lib/cli_commands.dart
+++ b/lib/cli_commands.dart
@@ -6,6 +6,7 @@ library;
import 'dart:isolate';
import 'package:ansicolor/ansicolor.dart';
+import 'package:html/dom.dart';
import 'package:html/parser.dart' as html_parser;
import 'package:image/image.dart';
import 'package:meta/meta.dart';
diff --git a/lib/templates.dart b/lib/templates.dart
old mode 100644
new mode 100755
index 010baed..8a14807
--- a/lib/templates.dart
+++ b/lib/templates.dart
@@ -406,7 +406,7 @@ const String _iOSBrandingRightBottomConstraints = '''
/// Web related templates
const String _webCss = '''
- \n';
+ cssContent += ' ';
// Add css as an inline style in head tag
final webIndex = File(_webIndex);
final document = html_parser.parse(webIndex.readAsStringSync());
// Update splash css style tag
- document.head
- ?..querySelector('style#splash-screen-style')?.remove()
- ..append(
- html_parser.parseFragment(cssContent, container: ''),
- );
+ Element? splashScreenStyle =
+ document.querySelector('style#splash-screen-style');
+ if (splashScreenStyle == null) {
+ document.head?.append(html_parser.parseFragment(
+ "\n $cssContent",
+ container: '',
+ ));
+ } else {
+ splashScreenStyle.replaceWith(html_parser.parseFragment(
+ cssContent,
+ container: '',
+ ));
+ }
// Write the updated index.html
webIndex.writeAsStringSync(document.outerHtml);
@@ -319,11 +325,19 @@ void _createSplashJs() {
final document = html_parser.parse(webIndex.readAsStringSync());
// Update splash js script tag
- document.head
- ?..querySelector('script#splash-screen-script')?.remove()
- ..append(
- html_parser.parseFragment(_webJS, container: ''),
- );
+ Element? splashScreenScript =
+ document.querySelector('script#splash-screen-script');
+ if (splashScreenScript == null) {
+ document.head?.append(html_parser.parseFragment(
+ "\n\n $_webJS\n",
+ container: '',
+ ));
+ } else {
+ splashScreenScript.replaceWith(html_parser.parseFragment(
+ _webJS,
+ container: '',
+ ));
+ }
// Write the updated index.html
webIndex.writeAsStringSync(document.outerHtml);
@@ -365,40 +379,64 @@ void _updateHtml({
?.remove();
// Update splash image
- document.querySelector('picture#splash')?.remove();
- document.querySelector('div#splash')?.remove();
- if (imagePath != null) {
- document.body?.insertBefore(
- html_parser.parseFragment(
- '\n${_indexHtmlPicture.replaceAll(
- '[IMAGEMODE]',
- imageMode,
- ).replaceAll(
- '[IMAGEEXTENSION]',
- imagePath.endsWith('.gif') ? 'gif' : 'png',
- )}',
+ Element? splashPicture = document.querySelector('picture#splash');
+ if (imagePath == null) {
+ splashPicture?.remove();
+ } else {
+ final fragmentContent = _indexHtmlPicture
+ .replaceAll(
+ '[IMAGEMODE]',
+ imageMode,
+ )
+ .replaceAll(
+ '[IMAGEEXTENSION]',
+ imagePath.endsWith('.gif') ? 'gif' : 'png',
+ );
+ if (splashPicture == null) {
+ document.body?.insertBefore(
+ html_parser.parseFragment(
+ "\n $fragmentContent\n",
+ container: '',
+ ),
+ document.body?.firstChild,
+ );
+ } else {
+ splashPicture.replaceWith(html_parser.parseFragment(
+ fragmentContent,
container: '',
- ),
- document.body?.firstChild,
- );
+ ));
+ }
}
// Update branding image
- document.querySelector('picture#splash-branding')?.remove();
- if (brandingImagePath != null) {
- document.body?.insertBefore(
- html_parser.parseFragment(
- '\n${_indexHtmlBrandingPicture.replaceAll(
- '[BRANDINGMODE]',
- brandingMode,
- ).replaceAll(
- '[BRANDINGEXTENSION]',
- brandingImagePath.endsWith('.gif') ? 'gif' : 'png',
- )}',
+ Element? splashBrandingPicture =
+ document.querySelector('picture#splash-branding');
+ if (brandingImagePath == null) {
+ splashBrandingPicture?.remove();
+ } else {
+ final fragmentContent = _indexHtmlBrandingPicture
+ .replaceAll(
+ '[BRANDINGMODE]',
+ brandingMode,
+ )
+ .replaceAll(
+ '[BRANDINGEXTENSION]',
+ brandingImagePath.endsWith('.gif') ? 'gif' : 'png',
+ );
+ if (splashBrandingPicture == null) {
+ document.body?.insertBefore(
+ html_parser.parseFragment(
+ "\n $fragmentContent\n",
+ container: '',
+ ),
+ document.body?.firstChild,
+ );
+ } else {
+ splashBrandingPicture.replaceWith(html_parser.parseFragment(
+ fragmentContent,
container: '',
- ),
- document.body?.firstChild,
- );
+ ));
+ }
}
// Write the updated index.html
From f77d0110e016dcd7e5980b744b126e831556631b Mon Sep 17 00:00:00 2001
From: Severin Hamader
Date: Wed, 3 Jun 2026 02:35:35 +0200
Subject: [PATCH 2/3] Remove import
---
lib/cli_commands.dart | 1 -
lib/web.dart | 10 ++++------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart
index 0e58ee5..1779ef1 100755
--- a/lib/cli_commands.dart
+++ b/lib/cli_commands.dart
@@ -6,7 +6,6 @@ library;
import 'dart:isolate';
import 'package:ansicolor/ansicolor.dart';
-import 'package:html/dom.dart';
import 'package:html/parser.dart' as html_parser;
import 'package:image/image.dart';
import 'package:meta/meta.dart';
diff --git a/lib/web.dart b/lib/web.dart
index ed2cce8..772656d 100755
--- a/lib/web.dart
+++ b/lib/web.dart
@@ -301,8 +301,7 @@ void _createSplashCss({
final document = html_parser.parse(webIndex.readAsStringSync());
// Update splash css style tag
- Element? splashScreenStyle =
- document.querySelector('style#splash-screen-style');
+ var splashScreenStyle = document.querySelector('style#splash-screen-style');
if (splashScreenStyle == null) {
document.head?.append(html_parser.parseFragment(
"\n $cssContent",
@@ -325,7 +324,7 @@ void _createSplashJs() {
final document = html_parser.parse(webIndex.readAsStringSync());
// Update splash js script tag
- Element? splashScreenScript =
+ var splashScreenScript =
document.querySelector('script#splash-screen-script');
if (splashScreenScript == null) {
document.head?.append(html_parser.parseFragment(
@@ -379,7 +378,7 @@ void _updateHtml({
?.remove();
// Update splash image
- Element? splashPicture = document.querySelector('picture#splash');
+ var splashPicture = document.querySelector('picture#splash');
if (imagePath == null) {
splashPicture?.remove();
} else {
@@ -409,8 +408,7 @@ void _updateHtml({
}
// Update branding image
- Element? splashBrandingPicture =
- document.querySelector('picture#splash-branding');
+ var splashBrandingPicture = document.querySelector('picture#splash-branding');
if (brandingImagePath == null) {
splashBrandingPicture?.remove();
} else {
From 00307c29461fe54053f8c35a27757664625ce9ee Mon Sep 17 00:00:00 2001
From: Severin Hamader
Date: Wed, 3 Jun 2026 02:37:36 +0200
Subject: [PATCH 3/3] Revert file mode changes
---
lib/cli_commands.dart | 0
lib/templates.dart | 0
lib/web.dart | 0
3 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 lib/cli_commands.dart
mode change 100755 => 100644 lib/templates.dart
mode change 100755 => 100644 lib/web.dart
diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart
old mode 100755
new mode 100644
diff --git a/lib/templates.dart b/lib/templates.dart
old mode 100755
new mode 100644
diff --git a/lib/web.dart b/lib/web.dart
old mode 100755
new mode 100644