From 7632ccc6d95cf4b0d02760f6d259495e7a1d09d0 Mon Sep 17 00:00:00 2001 From: Luka S Date: Thu, 12 Sep 2024 20:25:07 +0100 Subject: [PATCH] chore(example): added WASM support to example (#1885) --- .github/workflows/branch.yml | 2 +- .github/workflows/master.yml | 2 +- example/lib/widgets/drawer/menu_drawer.dart | 9 +++++++++ example/pubspec.yaml | 8 ++++---- firebase.json | 17 ++++++++++++++++- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml index 1798d9128..5e62a2ba5 100644 --- a/.github/workflows/branch.yml +++ b/.github/workflows/branch.yml @@ -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: diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 335ccd9f8..07f01a897 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -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: diff --git a/example/lib/widgets/drawer/menu_drawer.dart b/example/lib/widgets/drawer/menu_drawer.dart index b66ad2acb..14a4cab6b 100644 --- a/example/lib/widgets/drawer/menu_drawer.dart +++ b/example/lib/widgets/drawer/menu_drawer.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_map_example/pages/animated_map_controller.dart'; import 'package:flutter_map_example/pages/bundled_offline_map.dart'; @@ -33,6 +34,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; @@ -61,6 +64,12 @@ class MenuDrawer extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle(fontSize: 14), ), + if (kIsWeb) + const Text( + _isWASM ? 'Running with WASM' : 'Running without WASM', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 14), + ), ], ), ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index be2e58452..705010e06 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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.2 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: diff --git a/firebase.json b/firebase.json index 6adbf8c5b..4824c2b57 100644 --- a/firebase.json +++ b/firebase.json @@ -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" + } + ] + } ] } -} +} \ No newline at end of file