Skip to content

Commit 5756e80

Browse files
authored
Committing the web folder
1 parent 99f0e85 commit 5756e80

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

web/favicon.png

917 Bytes
Loading

web/icons/Icon-192.png

5.17 KB
Loading

web/icons/Icon-512.png

8.06 KB
Loading

web/index.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!--
5+
If you are serving your web app in a path other than the root, change the
6+
href value below to reflect the base path you are serving from.
7+
8+
The path provided below has to start and end with a slash "/" in order for
9+
it to work correctly.
10+
11+
For more details:
12+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
13+
-->
14+
<base href="/">
15+
16+
<meta charset="UTF-8">
17+
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
18+
<meta name="description" content="A new Flutter project.">
19+
20+
<!-- iOS meta tags & icons -->
21+
<meta name="apple-mobile-web-app-capable" content="yes">
22+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
23+
<meta name="apple-mobile-web-app-title" content="flutter_maps_marker_animation">
24+
<link rel="apple-touch-icon" href="icons/Icon-192.png">
25+
26+
<title>flutter_maps_marker_animation</title>
27+
<link rel="manifest" href="manifest.json">
28+
</head>
29+
<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>
97+
</body>
98+
</html>

web/manifest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "flutter_maps_marker_animation",
3+
"short_name": "flutter_maps_marker_animation",
4+
"start_url": ".",
5+
"display": "standalone",
6+
"background_color": "#0175C2",
7+
"theme_color": "#0175C2",
8+
"description": "A new Flutter project.",
9+
"orientation": "portrait-primary",
10+
"prefer_related_applications": false,
11+
"icons": [
12+
{
13+
"src": "icons/Icon-192.png",
14+
"sizes": "192x192",
15+
"type": "image/png"
16+
},
17+
{
18+
"src": "icons/Icon-512.png",
19+
"sizes": "512x512",
20+
"type": "image/png"
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)