0.1.7 • Published 5 years ago

flutter-web-wasm v0.1.7

Weekly downloads
25
License
-
Repository
-
Last release
5 years ago

A template for kick starting a Rust and WebAssembly project using wasm-pack.

Built with 🦀🕸 by The Rust and WebAssembly Working Group

About

📚 Read this template tutorial! 📚

This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting package to NPM.

Be sure to check out other wasm-pack tutorials online for other templates and usages of wasm-pack.

🚴 Usage

🐑 Use cargo generate to Clone this Template

Learn more about cargo generate here.

cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
cd my-project

🛠️ Build with wasm-pack build

wasm-pack build

🔬 Test in Headless Browsers with wasm-pack test

wasm-pack test --headless --firefox

Generate your dart bindings

rm -rf lib/src/flutter_web_wasm_base.dart
dart_js_facade_gen pkg/flutter_web_wasm.d.ts | tee lib/src/flutter_web_wasm_base.dart

🎁 Publish to NPM with wasm-pack publish

wasm-pack publish

Add your depedency Flutter side

In example/lib/web/index.html import your js library via script tag

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>example</title>
</head>

<body>
  <script src="main.dart.js" type="application/javascript"></script>
  <script src="https://unpkg.com/flutter-web-wasm@0.1.0/flutter_web_wasm.js"></script>  <!-- Import your freshly generated library from unpk cdn -->
</body>

</html>

In your example/lib/main.dart import your library

import 'package:flutter_web_wasm/flutter_web_wasm.dart';

🔋 Batteries Included

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago