Skip to content

Commit 9965e31

Browse files
chore: ⚡ Update web example as per latest flutter version
1 parent 61b00ba commit 9965e31

File tree

8 files changed

+59
-72
lines changed

8 files changed

+59
-72
lines changed

example/.metadata

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,42 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 8b114482a4b56c45ebc85f048156039b93a4bbd8
8-
channel: master
7+
revision: "edada7c56edf4a183c1735310e123c7f923584f1"
8+
channel: "stable"
99

1010
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
17+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
18+
- platform: android
19+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
20+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
21+
- platform: ios
22+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
23+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
24+
- platform: linux
25+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
26+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
27+
- platform: macos
28+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
29+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
30+
- platform: web
31+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
32+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
33+
- platform: windows
34+
create_revision: edada7c56edf4a183c1735310e123c7f923584f1
35+
base_revision: edada7c56edf4a183c1735310e123c7f923584f1
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/web/favicon.png

-124 Bytes
Loading

example/web/icons/Icon-192.png

21.1 KB
Loading

example/web/icons/Icon-512.png

119 KB
Loading
26.3 KB
Loading
127 KB
Loading

example/web/index.html

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,89 +10,29 @@
1010
1111
For more details:
1212
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
13+
14+
This is a placeholder for base href that will be replaced by the value of
15+
the `--base-href` argument provided to `flutter build`.
1316
-->
14-
<base href="/">
17+
<base href="$FLUTTER_BASE_HREF">
1518

1619
<meta charset="UTF-8">
1720
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
1821
<meta name="description" content="A new Flutter project.">
1922

2023
<!-- iOS meta tags & icons -->
21-
<meta name="apple-mobile-web-app-capable" content="yes">
24+
<meta name="mobile-web-app-capable" content="yes">
2225
<meta name="apple-mobile-web-app-status-bar-style" content="black">
2326
<meta name="apple-mobile-web-app-title" content="example">
2427
<link rel="apple-touch-icon" href="icons/Icon-192.png">
2528

29+
<!-- Favicon -->
30+
<link rel="icon" type="image/png" href="favicon.png"/>
31+
2632
<title>example</title>
2733
<link rel="manifest" href="manifest.json">
2834
</head>
2935
<body>
30-
<!-- This script installs service_worker.js to provide PWA functionality to
31-
application. For more information, see:
32-
https://developers.google.com/web/fundamentals/primers/service-workers -->
33-
<script>
34-
var serviceWorkerVersion = null;
35-
var scriptLoaded = false;
36-
function loadMainDartJs() {
37-
if (scriptLoaded) {
38-
return;
39-
}
40-
scriptLoaded = true;
41-
var scriptTag = document.createElement('script');
42-
scriptTag.src = 'main.dart.js';
43-
scriptTag.type = 'application/javascript';
44-
document.body.append(scriptTag);
45-
}
46-
47-
if ('serviceWorker' in navigator) {
48-
// Service workers are supported. Use them.
49-
window.addEventListener('load', function () {
50-
// Wait for registration to finish before dropping the <script> tag.
51-
// Otherwise, the browser will load the script multiple times,
52-
// potentially different versions.
53-
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
54-
navigator.serviceWorker.register(serviceWorkerUrl)
55-
.then((reg) => {
56-
function waitForActivation(serviceWorker) {
57-
serviceWorker.addEventListener('statechange', () => {
58-
if (serviceWorker.state == 'activated') {
59-
console.log('Installed new service worker.');
60-
loadMainDartJs();
61-
}
62-
});
63-
}
64-
if (!reg.active && (reg.installing || reg.waiting)) {
65-
// No active web worker and we have installed or are installing
66-
// one for the first time. Simply wait for it to activate.
67-
waitForActivation(reg.installing ?? reg.waiting);
68-
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
69-
// When the app updates the serviceWorkerVersion changes, so we
70-
// need to ask the service worker to update.
71-
console.log('New service worker available.');
72-
reg.update();
73-
waitForActivation(reg.installing);
74-
} else {
75-
// Existing service worker is still good.
76-
console.log('Loading app from service worker.');
77-
loadMainDartJs();
78-
}
79-
});
80-
81-
// If service worker doesn't succeed in a reasonable amount of time,
82-
// fallback to plaint <script> tag.
83-
setTimeout(() => {
84-
if (!scriptLoaded) {
85-
console.warn(
86-
'Failed to load app from service worker. Falling back to plain <script> tag.',
87-
);
88-
loadMainDartJs();
89-
}
90-
}, 4000);
91-
});
92-
} else {
93-
// Service workers not supported. Just drop the <script> tag.
94-
loadMainDartJs();
95-
}
96-
</script>
36+
<script src="flutter_bootstrap.js" async></script>
9737
</body>
9838
</html>

example/web/manifest.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"display": "standalone",
66
"background_color": "#0175C2",
77
"theme_color": "#0175C2",
8-
"description": "A new Flutter project.",
8+
"description": "Showcase Preview",
99
"orientation": "portrait-primary",
1010
"prefer_related_applications": false,
1111
"icons": [
@@ -18,6 +18,18 @@
1818
"src": "icons/Icon-512.png",
1919
"sizes": "512x512",
2020
"type": "image/png"
21+
},
22+
{
23+
"src": "icons/Icon-maskable-192.png",
24+
"sizes": "192x192",
25+
"type": "image/png",
26+
"purpose": "maskable"
27+
},
28+
{
29+
"src": "icons/Icon-maskable-512.png",
30+
"sizes": "512x512",
31+
"type": "image/png",
32+
"purpose": "maskable"
2133
}
2234
]
2335
}

0 commit comments

Comments
 (0)