Skip to content

Commit c44509f

Browse files
authored
Fix web background image (#459)
* Fixes display of background_image in web * Fixes black color in light mode
1 parent b662516 commit c44509f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/templates.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,13 @@ const String _iOSBrandingRightBottomConstraints = '''
406406

407407
/// Web related templates
408408
const String _webCss = '''
409+
html {
410+
height: 100%
411+
}
412+
409413
body {
410-
margin:0;
411-
height:100%;
414+
margin: 0;
415+
min-height: 100%;
412416
background-color: [LIGHTBACKGROUNDCOLOR];
413417
[LIGHTBACKGROUNDIMAGE]
414418
background-size: 100% 100%;
@@ -465,11 +469,8 @@ const String _webCssDark = '''
465469
466470
@media (prefers-color-scheme: dark) {
467471
body {
468-
margin:0;
469-
height:100%;
470472
background-color: [DARKBACKGROUNDCOLOR];
471473
[DARKBACKGROUNDIMAGE]
472-
background-size: 100% 100%;
473474
}
474475
}
475476
''';

lib/web.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ part of flutter_native_splash_cli;
44
class _WebLaunchImageTemplate {
55
final String fileName;
66
final double pixelDensity;
7+
78
_WebLaunchImageTemplate({required this.fileName, required this.pixelDensity});
89
}
910

@@ -171,10 +172,10 @@ void _createSplashCss({
171172
required bool hasDarkImage,
172173
}) {
173174
print('[Web] Creating CSS');
174-
color ??= '000000';
175+
color ??= 'ffffff';
175176
var cssContent = _webCss.replaceFirst('[LIGHTBACKGROUNDCOLOR]', '#$color');
176177
if (darkColor != null || darkBackgroundImage != null || hasDarkImage) {
177-
darkColor ??= color;
178+
darkColor ??= '000000';
178179
cssContent +=
179180
_webCssDark.replaceFirst('[DARKBACKGROUNDCOLOR]', '#$darkColor');
180181
}

0 commit comments

Comments
 (0)