Skip to content

Commit a52d4c5

Browse files
committed
Roll back web fade as it was a breaking change. Fixes #628. Fixes #627. Fixes #622.
1 parent 2cc2d52 commit a52d4c5

8 files changed

Lines changed: 51 additions & 87 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [2.3.7] - (2023-Dec-06)
2+
3+
- Roll back web fade as it was a breaking change. Fixes [#628](https://github.com/jonbhanson/flutter_native_splash/issues/628). Fixes [#627](https://github.com/jonbhanson/flutter_native_splash/issues/627). Fixes [#622](https://github.com/jonbhanson/flutter_native_splash/issues/622).
4+
15
## [2.3.6] - (2023-Nov-20)
26

37
- Add fade between splash and app on web. Thanks [eggp](https://github.com/eggp) for the suggestion and example code. Closes [#608](https://github.com/jonbhanson/flutter_native_splash/issues/608).

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file.
2121

2222
```yaml
2323
dependencies:
24-
flutter_native_splash: ^2.3.6
24+
flutter_native_splash: ^2.3.7
2525
```
2626
2727
Don't forget to `flutter pub get`.
@@ -169,10 +169,6 @@ flutter_native_splash:
169169
# SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top], );
170170
#fullscreen: true
171171
172-
# On web, the splash screen fades out in 250ms. This fade delay can be adjusted by changing
173-
# the web_splash_fade_time_ms parameter.
174-
#web_splash_fade_time_ms: 250
175-
176172
# If you have changed the name(s) of your info.plist file(s), you can specify the filename(s)
177173
# with the info_plist_files parameter. Remove only the # characters in the three lines below,
178174
# do not remove any spaces:

example/pubspec.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ packages:
6161
dependency: transitive
6262
description:
6363
name: collection
64-
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
64+
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
6565
url: "https://pub.dev"
6666
source: hosted
67-
version: "1.17.2"
67+
version: "1.18.0"
6868
convert:
6969
dependency: transitive
7070
description:
@@ -124,7 +124,7 @@ packages:
124124
path: ".."
125125
relative: true
126126
source: path
127-
version: "2.3.6"
127+
version: "2.3.7"
128128
flutter_test:
129129
dependency: "direct dev"
130130
description: flutter
@@ -187,10 +187,10 @@ packages:
187187
dependency: transitive
188188
description:
189189
name: meta
190-
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
190+
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
191191
url: "https://pub.dev"
192192
source: hosted
193-
version: "1.9.1"
193+
version: "1.10.0"
194194
path:
195195
dependency: transitive
196196
description:
@@ -232,18 +232,18 @@ packages:
232232
dependency: transitive
233233
description:
234234
name: stack_trace
235-
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
235+
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
236236
url: "https://pub.dev"
237237
source: hosted
238-
version: "1.11.0"
238+
version: "1.11.1"
239239
stream_channel:
240240
dependency: transitive
241241
description:
242242
name: stream_channel
243-
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
243+
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
244244
url: "https://pub.dev"
245245
source: hosted
246-
version: "2.1.1"
246+
version: "2.1.2"
247247
string_scanner:
248248
dependency: transitive
249249
description:
@@ -264,10 +264,10 @@ packages:
264264
dependency: transitive
265265
description:
266266
name: test_api
267-
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
267+
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
268268
url: "https://pub.dev"
269269
source: hosted
270-
version: "0.6.0"
270+
version: "0.6.1"
271271
typed_data:
272272
dependency: transitive
273273
description:
@@ -296,10 +296,10 @@ packages:
296296
dependency: transitive
297297
description:
298298
name: web
299-
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
299+
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
300300
url: "https://pub.dev"
301301
source: hosted
302-
version: "0.1.4-beta"
302+
version: "0.3.0"
303303
xml:
304304
dependency: transitive
305305
description:
@@ -317,5 +317,5 @@ packages:
317317
source: hosted
318318
version: "3.1.2"
319319
sdks:
320-
dart: ">=3.1.0-185.0.dev <4.0.0"
320+
dart: ">=3.2.0-194.0.dev <4.0.0"
321321
flutter: ">=2.5.0"

example/pubspec.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@ flutter_native_splash:
230230
# SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top], );
231231
#fullscreen: true
232232

233-
# On web, the splash screen fades out in 250ms. This fade delay can be adjusted by changing
234-
# the web_splash_fade_time_ms parameter.
235-
#web_splash_fade_time_ms: 250
236-
237233
# If you have changed the name(s) of your info.plist file(s), you can specify the filename(s)
238234
# with the info_plist_files parameter. Remove only the # characters in the three lines below,
239235
# do not remove any spaces:

lib/cli_commands.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ void createSplashByConfig(Map<String, dynamic> config) {
119119
final String iosContentMode =
120120
config[_Parameter.iosContentMode] as String? ?? 'center';
121121
final webImageMode = config[_Parameter.webImageMode] as String? ?? 'center';
122-
final fadeTimeMs = config[_Parameter.fadeTimeMs] as int? ?? 250;
123122
String? android12Image;
124123
String? android12DarkImage;
125124
String? android12IconBackgroundColor;
@@ -215,7 +214,6 @@ void createSplashByConfig(Map<String, dynamic> config) {
215214
darkColor: darkColorWeb ?? darkColor,
216215
imageMode: webImageMode,
217216
brandingMode: brandingGravity,
218-
fadeTimeMs: fadeTimeMs,
219217
);
220218
} else {
221219
print('Web folder not found, skipping web splash update...');
@@ -457,7 +455,6 @@ class _Parameter {
457455
static const plistFiles = 'info_plist_files';
458456
static const web = 'web';
459457
static const webImageMode = 'web_image_mode';
460-
static const fadeTimeMs = 'web_splash_fade_time_ms';
461458

462459
static List<String> all = [
463460
android,
@@ -505,6 +502,5 @@ class _Parameter {
505502
plistFiles,
506503
web,
507504
webImageMode,
508-
fadeTimeMs,
509505
];
510506
}

lib/templates.dart

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -407,34 +407,19 @@ const String _iOSBrandingRightBottomConstraints = '''
407407
/// Web related templates
408408
const String _webCss = '''
409409
<style id="splash-screen-style">
410-
.flutter-loader {
411-
z-index: 999999;
410+
html {
411+
height: 100%
412412
}
413-
414-
#splash {
415-
position: fixed;
416-
width: 100%;
417-
height: 100%;
418-
top: 0px;
419-
left: 0px;
420-
z-index: 999998;
421-
opacity: 1;
422-
/* animation type and duration */
423-
transition: opacity [FADETIME];
424-
background-color: [LIGHTBACKGROUNDCOLOR];
425-
[LIGHTBACKGROUNDIMAGE]
426-
-moz-osx-font-smoothing: grayscale;
427-
-webkit-font-smoothing: antialiased;
428-
}
429-
430-
#splash.remove {
431-
/* enable click through when run animation */
432-
pointer-events: none;
433-
/* start animation */
434-
opacity: 0;
413+
414+
body {
415+
margin: 0;
416+
min-height: 100%;
417+
background-color: [LIGHTBACKGROUNDCOLOR];
418+
[LIGHTBACKGROUNDIMAGE]
419+
background-size: 100% 100%;
435420
}
436421
437-
#splash .center {
422+
.center {
438423
margin: 0;
439424
position: absolute;
440425
top: 50%;
@@ -443,38 +428,38 @@ const String _webCss = '''
443428
transform: translate(-50%, -50%);
444429
}
445430
446-
#splash .contain {
431+
.contain {
447432
display:block;
448433
width:100%; height:100%;
449434
object-fit: contain;
450435
}
451436
452-
#splash .stretch {
437+
.stretch {
453438
display:block;
454439
width:100%; height:100%;
455440
}
456441
457-
#splash .cover {
442+
.cover {
458443
display:block;
459444
width:100%; height:100%;
460445
object-fit: cover;
461446
}
462447
463-
#splash .bottom {
448+
.bottom {
464449
position: absolute;
465450
bottom: 0;
466451
left: 50%;
467452
-ms-transform: translate(-50%, 0);
468453
transform: translate(-50%, 0);
469454
}
470455
471-
#splash .bottomLeft {
456+
.bottomLeft {
472457
position: absolute;
473458
bottom: 0;
474459
left: 0;
475460
}
476461
477-
#splash .bottomRight {
462+
.bottomRight {
478463
position: absolute;
479464
bottom: 0;
480465
right: 0;
@@ -484,7 +469,7 @@ const String _webCss = '''
484469
const String _webCssDark = '''
485470
486471
@media (prefers-color-scheme: dark) {
487-
#splash {
472+
body {
488473
background-color: [DARKBACKGROUNDCOLOR];
489474
[DARKBACKGROUNDIMAGE]
490475
}
@@ -493,13 +478,11 @@ const String _webCssDark = '''
493478

494479
// XML's insertBefore can't have a newline at the end:
495480
const String _indexHtmlPicture = '''
496-
<div id="splash">
497-
<picture>
498-
<source srcset="splash/img/light-1x.[IMAGEEXTENSION] 1x, splash/img/light-2x.[IMAGEEXTENSION] 2x, splash/img/light-3x.[IMAGEEXTENSION] 3x, splash/img/light-4x.[IMAGEEXTENSION] 4x" media="(prefers-color-scheme: light)">
499-
<source srcset="splash/img/dark-1x.[IMAGEEXTENSION] 1x, splash/img/dark-2x.[IMAGEEXTENSION] 2x, splash/img/dark-3x.[IMAGEEXTENSION] 3x, splash/img/dark-4x.[IMAGEEXTENSION] 4x" media="(prefers-color-scheme: dark)">
500-
<img class="[IMAGEMODE]" aria-hidden="true" src="splash/img/light-1x.[IMAGEEXTENSION]" alt=""/>
501-
</picture>
502-
</div>''';
481+
<picture id="splash">
482+
<source srcset="splash/img/light-1x.[IMAGEEXTENSION] 1x, splash/img/light-2x.[IMAGEEXTENSION] 2x, splash/img/light-3x.[IMAGEEXTENSION] 3x, splash/img/light-4x.[IMAGEEXTENSION] 4x" media="(prefers-color-scheme: light)">
483+
<source srcset="splash/img/dark-1x.[IMAGEEXTENSION] 1x, splash/img/dark-2x.[IMAGEEXTENSION] 2x, splash/img/dark-3x.[IMAGEEXTENSION] 3x, splash/img/dark-4x.[IMAGEEXTENSION] 4x" media="(prefers-color-scheme: dark)">
484+
<img class="[IMAGEMODE]" aria-hidden="true" src="splash/img/light-1x.[IMAGEEXTENSION]" alt=""/>
485+
</picture>''';
503486

504487
// XML's insertBefore can't have a newline at the end:
505488
const String _indexHtmlBrandingPicture = '''
@@ -512,12 +495,9 @@ const String _indexHtmlBrandingPicture = '''
512495
const String _webJS = '''
513496
<script id="splash-screen-script">
514497
function removeSplashFromWeb() {
515-
const splashElement = document.getElementById("splash");
516-
splashElement.classList.add("remove");
517-
setTimeout(function () {
518-
splashElement.remove();
519-
document.getElementById("splash-screen-script")?.remove();
520-
}, [FADETIME] /* animation time + wait rendering and others(500ms) */);
498+
document.getElementById("splash")?.remove();
499+
document.getElementById("splash-branding")?.remove();
500+
document.body.style.background = "transparent";
521501
}
522502
</script>
523503
''';

lib/web.dart

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ void _createWebSplash({
2020
required String brandingMode,
2121
required String? backgroundImage,
2222
required String? darkBackgroundImage,
23-
required int fadeTimeMs,
2423
}) {
2524
if (!File(_webIndex).existsSync()) {
2625
print('[Web] $_webIndex not found. Skipping Web.');
@@ -167,9 +166,8 @@ void _createWebSplash({
167166
darkBackgroundImage: darkBackgroundImage,
168167
backgroundImage: backgroundImage,
169168
hasDarkImage: darkBackgroundImage != null,
170-
fadeTimeMs: fadeTimeMs,
171169
);
172-
_createSplashJs(fadeTimeMs: fadeTimeMs);
170+
_createSplashJs();
173171
_updateHtml(
174172
imageMode: imageMode,
175173
imagePath: imagePath,
@@ -262,13 +260,10 @@ void _createSplashCss({
262260
required String? backgroundImage,
263261
required String? darkBackgroundImage,
264262
required bool hasDarkImage,
265-
required int fadeTimeMs,
266263
}) {
267264
print('[Web] Creating CSS');
268265
color ??= 'ffffff';
269-
var cssContent = _webCss
270-
.replaceFirst('[LIGHTBACKGROUNDCOLOR]', '#$color')
271-
.replaceFirst('[FADETIME]', "${fadeTimeMs / 1000}s");
266+
var cssContent = _webCss.replaceFirst('[LIGHTBACKGROUNDCOLOR]', '#$color');
272267
if (darkColor != null || darkBackgroundImage != null || hasDarkImage) {
273268
darkColor ??= '000000';
274269
cssContent += _webCssDark.replaceFirst(
@@ -317,7 +312,7 @@ void _createSplashCss({
317312
webIndex.writeAsStringSync(document.outerHtml);
318313
}
319314

320-
void _createSplashJs({required int fadeTimeMs}) {
315+
void _createSplashJs() {
321316
// Add js as an inline script in head tag
322317
final webIndex = File(_webIndex);
323318
final document = html_parser.parse(webIndex.readAsStringSync());
@@ -326,9 +321,7 @@ void _createSplashJs({required int fadeTimeMs}) {
326321
document.head
327322
?..querySelector('script#splash-screen-script')?.remove()
328323
..append(
329-
html_parser.parseFragment(
330-
_webJS.replaceFirst("[FADETIME]", (fadeTimeMs + 500).toString()),
331-
container: ''),
324+
html_parser.parseFragment(_webJS, container: ''),
332325
);
333326

334327
// Write the updated index.html
@@ -392,8 +385,7 @@ void _updateHtml({
392385
// Update branding image
393386
document.querySelector('picture#splash-branding')?.remove();
394387
if (brandingImagePath != null) {
395-
var div = document.querySelector('div#splash');
396-
div?.insertBefore(
388+
document.body?.insertBefore(
397389
html_parser.parseFragment(
398390
'\n${_indexHtmlBrandingPicture.replaceAll(
399391
'[BRANDINGMODE]',
@@ -404,7 +396,7 @@ void _updateHtml({
404396
)}',
405397
container: '',
406398
),
407-
div.firstChild,
399+
document.body?.firstChild,
408400
);
409401
}
410402

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: flutter_native_splash
22
description: Customize Flutter's default white native splash screen with
33
background color and splash image. Supports dark mode, full screen, and more.
4-
version: 2.3.6
4+
version: 2.3.7
55
repository: https://github.com/jonbhanson/flutter_native_splash
66
issue_tracker: https://github.com/jonbhanson/flutter_native_splash/issues
77

0 commit comments

Comments
 (0)