Skip to content

Commit 3497617

Browse files
authored
Merge pull request #137 from flutter-news-app-full-source-code/aa
Refactor/web-initialization-enhancement
2 parents 600c3e1 + 0c33fea commit 3497617

File tree

14 files changed

+7
-65
lines changed

14 files changed

+7
-65
lines changed

lib/app/services/splash_screen_remover/splash_remover_stub.dart

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/app/services/splash_screen_remover/splash_remover_web.dart

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/app/services/splash_screen_remover/web_splash_remover.dart

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/main.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:device_preview/device_preview.dart';
22
import 'package:flutter/foundation.dart';
33
import 'package:flutter/material.dart';
44
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart';
5-
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/splash_screen_remover/web_splash_remover.dart';
65
import 'package:flutter_news_app_mobile_client_full_source_code/bootstrap.dart';
76

87
// Define the current application environment (production/development/demo).
@@ -17,13 +16,6 @@ void main() async {
1716

1817
final appWidget = await bootstrap(appConfig, appEnvironment);
1918

20-
// Only remove the splash screen on web after the app is ready.
21-
if (kIsWeb) {
22-
WidgetsBinding.instance.addPostFrameCallback((_) {
23-
removeSplashFromWeb();
24-
});
25-
}
26-
2719
if (appConfig.environment == AppEnvironment.demo && kIsWeb) {
2820
runApp(
2921
DevicePreview(

pubspec.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ flutter:
121121

122122
flutter_launcher_icons:
123123
image_path: assets/logo/flutter-news-app-full-source-code-dark-logo.png
124-
125124
android: "launcher_icon"
126125
min_sdk_android: 21
127-
128126
web:
129127
generate: true
130128
background_color: "#FFFFFF"
@@ -133,12 +131,8 @@ flutter_launcher_icons:
133131
flutter_native_splash:
134132
color: "#FFFFFF"
135133
color_dark: "#212121"
136-
137-
# Optional: Specify an image asset for the splash screen
138134
image: assets/logo/flutter-news-app-full-source-code-dark-logo.png
139135
image_dark: assets/logo/flutter-news-app-full-source-code-light-logo.png
140-
141-
# Ensure configuration is applied to both platforms
142136
android: true
143137
ios: true
144-
web: false
138+
web: true

web/index.html

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22
<html>
33

44
<head>
5-
<!--
6-
If you are serving your web app in a path other than the root, change the
7-
href value below to reflect the base path you are serving from.
8-
9-
The path provided below has to start and end with a slash "/" in order for
10-
it to work correctly.
11-
12-
For more details:
13-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
14-
15-
This is a placeholder for base href that will be replaced by the value of
16-
the `--base-href` argument provided to `flutter build`.
17-
-->
185
<base href="$FLUTTER_BASE_HREF">
196

207
<meta charset="UTF-8">
@@ -38,8 +25,6 @@
3825
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
3926

4027

41-
42-
4328
<style id="splash-screen-style">
4429
html {
4530
height: 100%
@@ -111,14 +96,9 @@
11196
function removeSplashFromWeb() {
11297
document.getElementById("splash")?.remove();
11398
document.getElementById("splash-branding")?.remove();
114-
document.getElementById("splash-container")?.remove();
11599
document.body.style.background = "transparent";
116100
}
117101
</script>
118-
<script>
119-
var serviceWorkerVersion = null;
120-
</script>
121-
<script src="flutter.js" defer></script>
122102
</head>
123103

124104
<body>
@@ -132,24 +112,15 @@
132112
<img class="center" aria-hidden="true" src="splash/img/light-1x.png" alt="">
133113
</picture>
134114

115+
116+
135117
<div id="splash-container" class="center">
136118
<div class="loader"></div>
137119
</div>
138-
<script>
139-
window.addEventListener('load', function (ev) {
140-
// Download main.dart.js
141-
_flutter.loader.loadEntrypoint({
142-
serviceWorker: {
143-
serviceWorkerVersion: serviceWorkerVersion,
144-
},
145-
onEntrypointLoaded: function (engineInitializer) {
146-
engineInitializer.initializeEngine().then(function (appRunner) {
147-
appRunner.runApp();
148-
});
149-
}
150-
});
151-
});
152-
</script>
120+
<script src="flutter_bootstrap.js" async></script>
121+
122+
123+
153124
</body>
154125

155126
</html>

web/splash/img/dark-1x.png

-7.63 KB
Loading

web/splash/img/dark-2x.png

-27.8 KB
Loading

web/splash/img/dark-3x.png

-54.9 KB
Loading

web/splash/img/dark-4x.png

-80 KB
Loading

0 commit comments

Comments
 (0)