fluttercommunity / wakelock_plus

Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
BSD 3-Clause "New" or "Revised" License
71 stars 54 forks source link

Error: 'dart:ffi' can't be imported when compiling to Wasm. #65

Closed uldall closed 3 months ago

uldall commented 4 months ago

When building for web using Flutter 3.22.2 I get the following error:

Target dart2wasm failed: ProcessException: Process exited abnormally with exit code 64:
*NOTE*: Compilation to WasmGC is experimental.
The support may change, or be removed, with no advance notice.

/home/cup/.pub-cache/hosted/pub.dev/ffi-2.1.2/lib/src/allocation.dart:5:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
/home/cup/.pub-cache/hosted/pub.dev/ffi-2.1.2/lib/src/utf16.dart:5:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
/home/cup/.pub-cache/hosted/pub.dev/ffi-2.1.2/lib/src/utf8.dart:6:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
/home/cup/.pub-cache/hosted/pub.dev/ffi-2.1.2/lib/src/arena.dart:8:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
/home/cup/.pub-cache/hosted/pub.dev/dbus-0.7.10/lib/src/getsid_windows.dart:1:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
/home/cup/.pub-cache/hosted/pub.dev/dbus-0.7.10/lib/src/getuid_linux.dart:1:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
  Command: /home/cup/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart compile wasm --packages=.dart_tool/package_config.json
  --extra-compiler-option=--dart-sdk=/home/cup/snap/flutter/common/flutter/bin/cache/dart-sdk
  --extra-compiler-option=--platform=/home/cup/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/kernel/dart2wasm_platform.dill
  --extra-compiler-option=--delete-tostring-package-uri=dart:ui --extra-compiler-option=--delete-tostring-package-uri=package:flutter --extra-compiler-option=--import-shared-memory
  --extra-compiler-option=--shared-memory-max-pages=32768 -Ddart.vm.product=true
  -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/ -DFLUTTER_WEB_AUTO_DETECT=false -DFLUTTER_WEB_USE_SKIA=false
  -DFLUTTER_WEB_USE_SKWASM=true --extra-compiler-option=--depfile=/media/cup/data/git/zoolander/.dart_tool/flutter_build/5389598c2a36d064db55a8edf57e320f/dart2wasm.d -O4 --no-name-section -o
  /media/cup/data/git/zoolander/.dart_tool/flutter_build/5389598c2a36d064db55a8edf57e320f/main.dart.wasm
  /media/cup/data/git/zoolander/.dart_tool/flutter_build/5389598c2a36d064db55a8edf57e320f/main.dart

The only dependency on dbus that I have in my project is from wakelock_plus:

├── wakelock_plus 1.2.5
│   ├── dbus 0.7.10
│   │   ├── args...
│   │   ├── ffi...
│   │   ├── meta...
│   │   └── xml...
│   ├── flutter...
│   ├── flutter_web_plugins...
│   ├── meta...
│   ├── package_info_plus...
│   ├── wakelock_plus_platform_interface 1.2.1
│   │   ├── flutter...
│   │   ├── meta...
│   │   └── plugin_platform_interface...
│   ├── web...
│   └── win32...

I am not sure if this should be fixed in wakelock_plus or dbus, but it prevents usage of wakelock_plus when building with wasm support as of Flutter 3.22.2.