Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(example): added WASM support to example #1885

Merged
merged 11 commits into from
Sep 12, 2024
2 changes: 1 addition & 1 deletion .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
channel: "stable"
cache: true
- name: Build Web Application
run: flutter build web --web-renderer canvaskit
run: flutter build web --wasm
- name: Archive Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
channel: "stable"
cache: true
- name: Build Web Application
run: flutter build web --web-renderer canvaskit
run: flutter build web --wasm
- name: Archive Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
12 changes: 6 additions & 6 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "0b591f2c82e9f59276ed68c7d4cbd63196f7c865"
revision: "7c6b7e9ca485f7eaaed913c6bb50f4be6da47e30"
channel: "beta"

project_type: app
Expand All @@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
base_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
- platform: android
create_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
base_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
create_revision: 7c6b7e9ca485f7eaaed913c6bb50f4be6da47e30
base_revision: 7c6b7e9ca485f7eaaed913c6bb50f4be6da47e30
- platform: web
create_revision: 7c6b7e9ca485f7eaaed913c6bb50f4be6da47e30
base_revision: 7c6b7e9ca485f7eaaed913c6bb50f4be6da47e30

# User provided section

Expand Down
7 changes: 7 additions & 0 deletions example/lib/widgets/drawer/menu_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import 'package:flutter_map_example/pages/tile_loading_error_handle.dart';
import 'package:flutter_map_example/pages/wms_tile_layer.dart';
import 'package:flutter_map_example/widgets/drawer/menu_item.dart';

const _isWASM = bool.fromEnvironment('dart.tool.dart2wasm');

class MenuDrawer extends StatelessWidget {
final String currentRoute;

Expand Down Expand Up @@ -61,6 +63,11 @@ class MenuDrawer extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14),
),
const Text(
_isWASM ? 'Running with WASM' : 'Running without WASM',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14),
),
JaffaKetchup marked this conversation as resolved.
Show resolved Hide resolved
],
),
),
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ dependencies:
flutter:
sdk: flutter
flutter_map:
flutter_map_cancellable_tile_provider: ^3.0.0
flutter_map_cancellable_tile_provider: ^3.0.1
flutter_map_geojson: ^1.0.8
http: ^1.2.1
http: ^1.2.2
latlong2: ^0.9.1
proj4dart: ^2.1.0
shared_preferences: ^2.2.3
shared_preferences: ^2.3.2
url_launcher: ^6.3.0
url_strategy: ^0.2.0
url_strategy: ^0.3.0
vector_math: ^2.1.4

dependency_overrides:
Expand Down
61 changes: 20 additions & 41 deletions example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<!--
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.

Expand All @@ -15,49 +15,28 @@
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description"
content="A versatile mapping package for Flutter, based off leaflet.js, that's simple and easy to learn, yet completely customizable and configurable.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="flutter_map Demo">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />

<title>flutter_map Demo</title>
<link rel="manifest" href="manifest.json">

<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
<base href="$FLUTTER_BASE_HREF">

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description"
content="A versatile mapping package for Flutter, based off leaflet.js, that's simple and easy to learn, yet completely customizable and configurable.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="flutter_map Demo">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />

<title>flutter_map Demo</title>
<link rel="manifest" href="manifest.json">
</head>

<body>
<script>
window.addEventListener('load', function (ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function (engineInitializer) {
engineInitializer.initializeEngine().then(function (appRunner) {
appRunner.runApp();
});
}
});
});
</script>
<script src="flutter_bootstrap.js" async></script>
</body>

</html>
17 changes: 16 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cross-Origin-Embedder-Policy",
"value": "credentialless"
},
{
"key": "Cross-Origin-Opener-Policy",
"value": "same-origin"
}
]
}
]
}
}
}
Loading