I am trying to get my current Flutter app to run on web. I called flutter create .
but if I try running it in Chrome I get prompted with about 10000 error messages which all look like this:
Try removing the 'external' keyword or adding a JS interop annotation. external ffi.Pointer<OBX_id_array> removals; ^
../../flutter/.pub-cache/hosted/pub.dartlang/objectbox-1.1.0/lib/src/native/bindings/objectbox-c.dart:6289:41: Error: Only JS interop members may be 'external'. Try removing the 'external' keyword or adding a JS interop annotation. external ffi.Pointer<OBX_sync_change> list; ^
../../flutter/.pub-cache/hosted/pub.dartlang/objectbox-1.1.0/lib/src/native/bindings/objectbox-c.dart:6292:16: Error: Only JS interop members may be 'external'. Try removing the 'external' keyword or adding a JS interop annotation. external int count; ^
Failed to pile application.
I tried googling it but I couldn't find anything on this. Does anyone know what this is about and how I can fit this??
I am trying to get my current Flutter app to run on web. I called flutter create .
but if I try running it in Chrome I get prompted with about 10000 error messages which all look like this:
Try removing the 'external' keyword or adding a JS interop annotation. external ffi.Pointer<OBX_id_array> removals; ^
../../flutter/.pub-cache/hosted/pub.dartlang/objectbox-1.1.0/lib/src/native/bindings/objectbox-c.dart:6289:41: Error: Only JS interop members may be 'external'. Try removing the 'external' keyword or adding a JS interop annotation. external ffi.Pointer<OBX_sync_change> list; ^
../../flutter/.pub-cache/hosted/pub.dartlang/objectbox-1.1.0/lib/src/native/bindings/objectbox-c.dart:6292:16: Error: Only JS interop members may be 'external'. Try removing the 'external' keyword or adding a JS interop annotation. external int count; ^
Failed to pile application.
I tried googling it but I couldn't find anything on this. Does anyone know what this is about and how I can fit this??
Share Improve this question asked Jul 13, 2021 at 20:06 ChrisChris 2,3149 gold badges63 silver badges145 bronze badges 1- 1 Well I was using moor db, I had to remove import 'package:moor/ffi.dart'; since it support only mobile devices – Kunchok Tashi Commented Sep 1, 2021 at 16:05
2 Answers
Reset to default 7Re-posting the answer from a GitHub issue here:
You can't build your app for the web with packages that don't support web, which ObjectBox doesn't yet (there's an issue you can track though).
Sometimes you may want to have the dependency in a small part of the code and it's fine if it doesn't work for the web, in that case, you can use "conditional imports", such as:
import 'myapp/sources-that-use-objectbox.dart' if (dart.library.html) 'myapp/sources-that-dont-use-objectbox.dart';
In my case I had accidentally used the "ffi" library which is not supported by the web. I then removed all the import made of this library in my code and I also removed the library from "pubsec.yaml". It now launches normally.