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

Better wasm support #232

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Better wasm support #232

wants to merge 2 commits into from

Conversation

simolus3
Copy link
Owner

  • As dart2wasm can't convert JS typed data instances into Dart instances without copying, we have to avoid dart:typed_data pretty much everywhere in code we intend to compile to WASM. This affects the VFS layer which is a breaking change.
  • todo there will probably be more changes required.

simolus3 added 2 commits May 19, 2024 16:21
As `dart2wasm` can't reference JS typed data instances and instead does a copy, a lot of things subtly break.
@hnvn
Copy link

hnvn commented Aug 14, 2024

I've got this error when trying to run flutter build web --wasm:

../../../.pub-cache/hosted/pub.dev/sqlite3-2.4.6/lib/src/ffi/memory.dart:2:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';

@simolus3
Copy link
Owner Author

You're importing package:sqlite3/sqlite3.dart somewhere, which does not support being compiled to wasm. You need to use conditional imports to only import package:sqlite3/wasm.dart (or package:sqlite3/common.dart for platform-agnostic code) when you compile your app to the web. If you're using drift you can use this package which takes care of that for you.

@hnvn
Copy link

hnvn commented Aug 15, 2024

Thank you @simolus3 , I get it work now, it's because of using old implementation that import sqlite3_flutter_libs manually. I followed new setup docs to add dependencies for drift and drift_flutter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants