一键导入
flutter-wasm-web
Best practices for compiling, optimizing, and deploying Flutter Web applications to WebAssembly (Wasm-GC) using modern JS interop.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Best practices for compiling, optimizing, and deploying Flutter Web applications to WebAssembly (Wasm-GC) using modern JS interop.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Audit and rewrite project changelogs to adhere strictly to Keep a Changelog and Semantic Versioning standards. Use when reviewing, drafting, or refining project changelogs.
Guide for utilizing the Genkit Dart SDK to build full-stack, AI-powered agentic applications.
Guide for utilizing Dart 3.0+ up to 3.12 syntax updates (private named parameters, extension types, records, pattern matching, wildcard variables, and primary constructors).
Optimize Dart code for performance, type safety, and runtime error prevention. Use when profiling hot paths, enforcing sound typing, handling null safety, or debugging type mismatches and runtime failures.
Run Dart tooling workflows for static analysis, dependency conflict resolution, and test migration to package:checks. Use when fixing analyzer errors, resolving pub dependency conflicts, or modernizing test assertions.
Configure and run integration tests using the integration_test package with Flutter Driver. Use when testing complete user flows, verifying navigation, or running end-to-end tests on devices or CI.
| name | flutter-wasm-web |
| description | Best practices for compiling, optimizing, and deploying Flutter Web applications to WebAssembly (Wasm-GC) using modern JS interop. |
| metadata | {"platforms":"flutter, web","languages":"dart, javascript","category":"web"} |
Flutter Web supports compilation to WebAssembly (Wasm-GC) for near-native UI rendering performance, smoother animations, and faster load times.
dart:js_interop and package:web)Compile your application to WebAssembly using the Flutter CLI:
flutter build web --wasm
Wasm-GC requires serving specific files with correct HTTP headers. Ensure your web host (Firebase Hosting, Cloudflare, Vercel, Nginx) includes:
Content-Type: application/wasm for the generated .wasm files.Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corpdart:js_interop and package:web)Wasm-GC compilation strictly prohibits using the legacy dart:html, dart:js, or package:js libraries. You must utilize the standard dart:js_interop and package:web packages.
dart:html. Import package:web/web.dart for DOM access.@JS() annotation for declaring external JavaScript functions.JSString, JSNumber, JSBool, JSAny, JSObject).import 'dart:js_interop';
import 'package:web/web.dart';
// Declare external JS API
@JS('console.log')
external void jsConsoleLog(JSAny message);
@JS('localStorage.setItem')
external void jsSetLocalStorage(JSString key, JSString value);
void main() {
// Convert Dart types to JS types
jsConsoleLog('Hello from Wasm-GC!'.toJS);
jsSetLocalStorage('app_mode'.toJS, 'dark'.toJS);
// Accessing the DOM via package:web
final windowEl = window;
jsConsoleLog(windowEl.location.href.toJS);
}
dart:iopackage:http (resolves to browser-native Fetch API) and use IndexedDB or local storage for caching.Isolate.spawn or compute() will throw runtime errors on web.pubspec.yaml to prevent fallback font rendering.flutter run -d chrome --wasm to run and debug locally under Wasm.