khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
89 stars 50 forks source link

Cannot compile for web #59

Closed r-ilagan closed 1 year ago

r-ilagan commented 1 year ago

Hello I'm having this issue where ffi isn't found when compiling for web. It works fine for mobile. Our app has a dependency override ffi: ^2.0.1

 Launching lib/main.dart on Chrome in debug mode...
: Error: Not found: 'dart:ffi'
import 'dart:ffi' as ffi;
       ^

: Error: Not found: 'dart:ffi'
import 'dart:ffi';
       ^
: Error: Not found: 'dart:ffi'
import 'dart:ffi';
       ^

: Error: Not found: 'dart:ffi'
import 'dart:ffi';
       ^

: Error: Not found: 'dart:ffi'
import 'dart:ffi';
       ^

: Error: Not found: 'dart:ffi'
import 'dart:ffi';
       ^

: Error: Not found: 'dart:ffi'
import 'dart:ffi';
       ^

: Error: Type 'ffi.NativeType' not found.
  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
                                          ^^^^^^^^^^^^^^
: Error: Type 'ffi.Pointer' not found.
  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
        ^^^^^^^^^^^

: Error: Type 'ffi.DynamicLibrary' not found.
  GeneratedBindings(ffi.DynamicLibrary dynamicLibrary)
                    ^^^^^^^^^^^^^^^^^^

: Error: Type 'ffi.NativeType' not found.
      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)

                                        ^^^^^^^^^^^^^^
: Error: Type 'ffi.Pointer' not found.
      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
      ^^^^^^^^^^^

: Error: Type 'ffi.Char' not found.
  ffi.Pointer<ffi.Char> version() {

              ^^^^^^^^
: Error: Type 'ffi.Pointer' not found.

  ffi.Pointer<ffi.Char> version() {
  ^^^^^^^^^^^
: Error: Type 'ffi.Char' not found.
    ffi.Pointer<ffi.Char> bytes,

                ^^^^^^^^
: Error: Type 'ffi.Pointer' not found.

    ffi.Pointer<ffi.Char> bytes,
    ^^^^^^^^^^^
: Error: Type 'ffi.Char' not found.
    ffi.Pointer<ffi.Char> bytes,

                ^^^^^^^^
: Error: Type 'ffi.Pointer' not found.
    ffi.Pointer<ffi.Char> bytes,

    ^^^^^^^^^^^
: Error: Type 'ffi.Char' not found.
    ffi.Pointer<ffi.Char> contents,
                ^^^^^^^^

: Error: Type 'ffi.Pointer' not found.
    ffi.Pointer<ffi.Char> contents,
    ^^^^^^^^^^^
: Error: Type 'ffi.Struct' not found.
class Pos extends ffi.Struct {
                  ^^^^^^^^^^

: Error: Type 'ffi.Struct' not found.
class CodeResult extends ffi.Struct {
                         ^^^^^^^^^^
: Error: Type 'ffi.Char' not found.
  external ffi.Pointer<ffi.Char> text;
                       ^^^^^^^^

: Error: Type 'ffi.Pointer' not found.
  external ffi.Pointer<ffi.Char> text;
           ^^^^^^^^^^^
: Error: Type 'ffi.UnsignedChar' not found.
  external ffi.Pointer<ffi.UnsignedChar> bytes;

                       ^^^^^^^^^^^^^^^^
: Error: Type 'ffi.Pointer' not found.

  external ffi.Pointer<ffi.UnsignedChar> bytes;
           ^^^^^^^^^^^
: Error: Type 'ffi.Pointer' not found.
  external ffi.Pointer<Pos> pos;

           ^^^^^^^^^^^
: Error: Type 'ffi.Struct' not found.
class CodeResults extends ffi.Struct {
                          ^^^^^^^^^^

: Error: Type 'ffi.Pointer' not found.
  external ffi.Pointer<CodeResult> results;
           ^^^^^^^^^^^
: Error: Type 'ffi.Struct' not found.
class EncodeResult extends ffi.Struct {

                           ^^^^^^^^^^
: Error: Type 'ffi.Char' not found.
  external ffi.Pointer<ffi.Char> text;
                       ^^^^^^^^

: Error: Type 'ffi.Pointer' not found.
  external ffi.Pointer<ffi.Char> text;
           ^^^^^^^^^^^
: Error: Type 'ffi.SignedChar' not found.

  external ffi.Pointer<ffi.SignedChar> data;
                       ^^^^^^^^^^^^^^
: Error: Type 'ffi.Pointer' not found.
  external ffi.Pointer<ffi.SignedChar> data;
           ^^^^^^^^^^^
: Error: Type 'ffi.Char' not found.
  external ffi.Pointer<ffi.Char> error;
                       ^^^^^^^^
: Error: Type 'ffi.Pointer' not found.
  external ffi.Pointer<ffi.Char> error;
           ^^^^^^^^^^^
: Error: Type 'DynamicLibrary' not found.
DynamicLibrary _openDynamicLibrary() {
^^^^^^^^^^^^^^

: Error: Type 'DynamicLibrary' not found.
DynamicLibrary dylib = _openDynamicLibrary();

^^^^^^^^^^^^^^
: Error: Type 'Char' not found.
  Pointer<Char> allocatePointer() {
          ^^^^
: Error: Type 'Pointer' not found.
  Pointer<Char> allocatePointer() {
  ^^^^^^^
: Error: Type 'DynamicLibrary' not found.
final DynamicLibrary stdlib = Platform.isWindows
      ^^^^^^^^^^^^^^
: Error: Type 'Pointer' not found.
typedef PosixMallocNative = Pointer Function(IntPtr);
                            ^^^^^^^
: Error: Type 'IntPtr' not found.
typedef PosixMallocNative = Pointer Function(IntPtr);
                                             ^^^^^^
: Error: Type 'Pointer' not found.
typedef PosixMalloc = Pointer Function(int);
                      ^^^^^^^
: Error: Type 'Pointer' not found.
typedef PosixCallocNative = Pointer Function(IntPtr num, IntPtr size);
                            ^^^^^^^
: Error: Type 'IntPtr' not found.
typedef PosixCallocNative = Pointer Function(IntPtr num, IntPtr size);
                                             ^^^^^^
: Error: Type 'IntPtr' not found.
typedef PosixCallocNative = Pointer Function(IntPtr num, IntPtr size);
                                                         ^^^^^^
: Error: Type 'Pointer' not found.
typedef PosixCalloc = Pointer Function(int num, int size);
                      ^^^^^^^
: Error: Type 'Void' not found.
typedef PosixFreeNative = Void Function(Pointer);
                          ^^^^
: Error: Type 'Pointer' not found.

typedef PosixFreeNative = Void Function(Pointer);
                                        ^^^^^^^
: Error: Type 'Pointer' not found.
typedef PosixFree = void Function(Pointer);
                                  ^^^^^^^
: Error: Type 'Pointer' not found.
typedef WinCoTaskMemAllocNative = Pointer Function(Size cb);
                                  ^^^^^^^
: Error: Type 'Size' not found.
typedef WinCoTaskMemAllocNative = Pointer Function(Size cb);
                                                   ^^^^
: Error: Type 'Pointer' not found.
typedef WinCoTaskMemAlloc = Pointer Function(int cb);
                            ^^^^^^^
: Error: Type 'Void' not found.
typedef WinCoTaskMemFreeNative = Void Function(Pointer pv);
                                 ^^^^
: Error: Type 'Pointer' not found.
typedef WinCoTaskMemFreeNative = Void Function(Pointer pv);
                                               ^^^^^^^
: Error: Type 'Pointer' not found.
typedef WinCoTaskMemFree = void Function(Pointer pv);
                                         ^^^^^^^
: Error: Type 'Allocator' not found.
class _MallocAllocator implements Allocator {
                                  ^^^^^^^^^
: Error: Type 'Pointer' not found.
  Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment}) {
  ^^^^^^^
: Error: Type 'NativeType' not found.
  Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment}) {
                                ^^^^^^^^^^
: Error: Type 'Pointer' not found.
  void free(Pointer pointer) {
            ^^^^^^^
: Error: Type 'Allocator' not found.
const Allocator malloc = _MallocAllocator();
      ^^^^^^^^^
: Error: Type 'Allocator' not found.
class _CallocAllocator implements Allocator {
                                  ^^^^^^^^^
: Error: Type 'Pointer' not found.
  void _fillMemory(Pointer destination, int length, int fill) {
                   ^^^^^^^
: Error: Type 'Pointer' not found.
  void _zeroMemory(Pointer destination, int length) =>
                   ^^^^^^^
: Error: Type 'Pointer' not found.
  Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment}) {
  ^^^^^^^
: Error: Type 'NativeType' not found.
  Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment}) {
                                ^^^^^^^^^^
: Error: Type 'Pointer' not found.
  void free(Pointer pointer) {
            ^^^^^^^
: Error: Type 'Allocator' not found.
const Allocator calloc = _CallocAllocator();
      ^^^^^^^^^
: Error: Type 'Allocator' not found.
class Arena implements Allocator {
                       ^^^^^^^^^
: Error: Type 'Allocator' not found.
  final Allocator _wrappedAllocator;
        ^^^^^^^^^
: Error: Type 'NativeType' not found.
  final List<Pointer<NativeType>> _managedMemoryPointers = [];
                     ^^^^^^^^^^
: Error: Type 'Pointer' not found.
  final List<Pointer<NativeType>> _managedMemoryPointers = [];
             ^^^^^^^
: Error: Type 'Allocator' not found.
  Arena([Allocator allocator = calloc]) : _wrappedAllocator = allocator;
         ^^^^^^^^^
: Error: Type 'Pointer' not found.
  Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment}) {
  ^^^^^^^
: Error: Type 'NativeType' not found.
  Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment}) {
                                ^^^^^^^^^^
: Error: Type 'NativeType' not found.
  void free(Pointer<NativeType> pointer) {}
                    ^^^^^^^^^^
: Error: Type 'Pointer' not found.
  void free(Pointer<NativeType> pointer) {}
            ^^^^^^^
: Error: Type 'Allocator' not found.
    [Allocator wrappedAllocator = calloc]) {
     ^^^^^^^^^
: Error: Type 'Allocator' not found.
    [Allocator wrappedAllocator = calloc]) {
     ^^^^^^^^^
: Error: Type 'Opaque' not found.
class Utf8 extends Opaque {}
                   ^^^^^^
: Error: Type 'Pointer' not found.
extension Utf8Pointer on Pointer<Utf8> {
                         ^^^^^^^
: Error: Type 'Uint8' not found.
  static int _length(Pointer<Uint8> codeUnits) {
                             ^^^^^
: Error: Type 'Pointer' not found.
  static int _length(Pointer<Uint8> codeUnits) {
                     ^^^^^^^
: Error: Type 'Pointer' not found.
  Pointer<Utf8> toNativeUtf8({Allocator allocator = malloc}) {
  ^^^^^^^
: Error: Type 'Allocator' not found.
  Pointer<Utf8> toNativeUtf8({Allocator allocator = malloc}) {
                              ^^^^^^^^^
: Error: Type 'Opaque' not found.
class Utf16 extends Opaque {}
                    ^^^^^^
: Error: Type 'Pointer' not found.
extension Utf16Pointer on Pointer<Utf16> {
                          ^^^^^^^
: Error: Type 'Uint16' not found.
  static String _toKnownLengthString(Pointer<Uint16> codeUnits, int length) =>

                                             ^^^^^^
: Error: Type 'Pointer' not found.

  static String _toKnownLengthString(Pointer<Uint16> codeUnits, int length) =>
                                     ^^^^^^^
: Error: Type 'Uint16' not found.
  static String _toUnknownLengthString(Pointer<Uint16> codeUnits) {
                                               ^^^^^^
: Error: Type 'Pointer' not found.
  static String _toUnknownLengthString(Pointer<Uint16> codeUnits) {
                                       ^^^^^^^
: Error: Type 'Uint16' not found.
  static int _length(Pointer<Uint16> codeUnits) {
                             ^^^^^^
: Error: Type 'Pointer' not found.
  static int _length(Pointer<Uint16> codeUnits) {
                     ^^^^^^^
: Error: Type 'Pointer' not found.
  Pointer<Utf16> toNativeUtf16({Allocator allocator = malloc}) {

  ^^^^^^^
: Error: Type 'Allocator' not found.
  Pointer<Utf16> toNativeUtf16({Allocator allocator = malloc}) {
                                ^^^^^^^^^

: Error: 'Void' isn't a type.
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('setLogEnabled');
                                     ^^^^
: Error: 'Int' isn't a type.
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('setLogEnabled');
                                                       ^^^
: Error: 'NativeFunction' isn't a type.
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('setLogEnabled');
                  ^^^^^^^^^^^^^^
: Error: 'Char' isn't a type.
      _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>('version');
                                                 ^^^^
: Error: 'Pointer' isn't a type.
      _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>('version');
                                     ^^^^^^^
: Error: 'NativeFunction' isn't a type.

      _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>('version');
                  ^^^^^^^^^^^^^^
: Error: 'Char' isn't a type.
      _versionPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();

                                             ^^^^
: Error: 'Pointer' isn't a type.

      _versionPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
                                 ^^^^^^^
: Error: 'Char' isn't a type.
          CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,
                                              ^^^^
: Error: 'Pointer' isn't a type.
          CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,

                                  ^^^^^^^
: Error: 'Int' isn't a type.
          CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,

                                                         ^^^
: Error: 'Int' isn't a type.

          CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,
                                                                  ^^^
: Error: 'Int' isn't a type.
          CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,
                                                                           ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcode');
                  ^^^
: Error: 'Int' isn't a type.

              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcode');
                           ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcode');
                                    ^^^
: Error: 'Int' isn't a type.

              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcode');
                                             ^^^
: Error: 'NativeFunction' isn't a type.
      ffi.NativeFunction<

          ^^^^^^^^^^^^^^
: Error: 'Char' isn't a type.
          ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>();

                          ^^^^
: Error: 'Pointer' isn't a type.

          ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>();
              ^^^^^^^
: Error: 'Char' isn't a type.
          CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,
                                               ^^^^
: Error: 'Pointer' isn't a type.
          CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,

                                   ^^^^^^^
: Error: 'Int' isn't a type.
          CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,

                                                          ^^^
: Error: 'Int' isn't a type.

          CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,
                                                                   ^^^
: Error: 'Int' isn't a type.
          CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int,
                                                                            ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcodes');
                  ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcodes');
                           ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcodes');
                                    ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcodes');
                                             ^^^
: Error: 'NativeFunction' isn't a type.
      ffi.NativeFunction<
          ^^^^^^^^^^^^^^
: Error: 'Char' isn't a type.
          ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>();
                          ^^^^
: Error: 'Pointer' isn't a type.
          ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>();
              ^^^^^^^
: Error: 'Char' isn't a type.
          EncodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int,
                                                ^^^^
: Error: 'Pointer' isn't a type.
          EncodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int,
                                    ^^^^^^^
: Error: 'Int' isn't a type.
          EncodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int,
                                                           ^^^
: Error: 'Int' isn't a type.
          EncodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int,
                                                                    ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int)>>('encodeBarcode');
                  ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int)>>('encodeBarcode');
                           ^^^
: Error: 'Int' isn't a type.
              ffi.Int, ffi.Int, ffi.Int)>>('encodeBarcode');
                                    ^^^
: Error: 'NativeFunction' isn't a type.
      ffi.NativeFunction<
          ^^^^^^^^^^^^^^
: Error: 'Char' isn't a type.
      EncodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>();
                                            ^^^^
: Error: 'Pointer' isn't a type.
      EncodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>();
                                ^^^^^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.

  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int32'.
  @ffi.Int32()
       ^^^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: Couldn't find constructor 'Int32'.
  @ffi.Int32()
       ^^^^^
: Error: Couldn't find constructor 'Int'.
  @ffi.Int()
       ^^^
: Error: 'NativeType' isn't a type.
  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
                                              ^^^^^^^^^^
: Error: 'Pointer' isn't a type.

  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
            ^^^^^^^
: Error: 'DynamicLibrary' isn't a type.
  GeneratedBindings(ffi.DynamicLibrary dynamicLibrary)
                        ^^^^^^^^^^^^^^
: Error: 'NativeType' isn't a type.
      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
                                            ^^^^^^^^^^
: Error: 'Pointer' isn't a type.
      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
          ^^^^^^^
: Error: 'Char' isn't a type.
    ffi.Pointer<ffi.Char> bytes,
                    ^^^^
: Error: 'Pointer' isn't a type.
    ffi.Pointer<ffi.Char> bytes,
        ^^^^^^^
: Error: 'Char' isn't a type.
    ffi.Pointer<ffi.Char> bytes,
                    ^^^^
: Error: 'Pointer' isn't a type.
    ffi.Pointer<ffi.Char> bytes,

        ^^^^^^^
: Error: 'Char' isn't a type.
    ffi.Pointer<ffi.Char> contents,
                    ^^^^

: Error: 'Pointer' isn't a type.
    ffi.Pointer<ffi.Char> contents,
        ^^^^^^^

: Error: 'Char' isn't a type.
  external ffi.Pointer<ffi.Char> text;
                           ^^^^
: Error: 'Pointer' isn't a type.
  external ffi.Pointer<ffi.Char> text;
               ^^^^^^^
: Error: 'UnsignedChar' isn't a type.
  external ffi.Pointer<ffi.UnsignedChar> bytes;

                           ^^^^^^^^^^^^
: Error: 'Pointer' isn't a type.

  external ffi.Pointer<ffi.UnsignedChar> bytes;
               ^^^^^^^
: Error: 'Pointer' isn't a type.
  external ffi.Pointer<Pos> pos;
               ^^^^^^^
: Error: 'Pointer' isn't a type.
  external ffi.Pointer<CodeResult> results;
               ^^^^^^^
: Error: 'Char' isn't a type.
  external ffi.Pointer<ffi.Char> text;
                           ^^^^
: Error: 'Pointer' isn't a type.
  external ffi.Pointer<ffi.Char> text;
               ^^^^^^^
: Error: 'SignedChar' isn't a type.
  external ffi.Pointer<ffi.SignedChar> data;
                           ^^^^^^^^^^
: Error: 'Pointer' isn't a type.

  external ffi.Pointer<ffi.SignedChar> data;
               ^^^^^^^
: Error: 'Char' isn't a type.
  external ffi.Pointer<ffi.Char> error;
                           ^^^^
: Error: 'Pointer' isn't a type.
  external ffi.Pointer<ffi.Char> error;

               ^^^^^^^
: Error: 'Char' isn't a type.
    contents.toNativeUtf8().cast<Char>(),
                                 ^^^^
: Error: Undefined name 'DynamicLibrary'.
    return DynamicLibrary.open('libflutter_zxing.so');
           ^^^^^^^^^^^^^^
: Error: Undefined name 'DynamicLibrary'.
    return DynamicLibrary.open('flutter_zxing_windows_plugin.dll');
           ^^^^^^^^^^^^^^
: Error: Undefined name 'DynamicLibrary'.
  return DynamicLibrary.process();
         ^^^^^^^^^^^^^^

: Error: 'DynamicLibrary' isn't a type.
DynamicLibrary dylib = _openDynamicLibrary();
^^^^^^^^^^^^^^

: Error: 'Int8' isn't a type.
    final Pointer<Int8> blob = calloc<Int8>(length);
                  ^^^^
: Error: 'Pointer' isn't a type.
    final Pointer<Int8> blob = calloc<Int8>(length);
          ^^^^^^^
: Error: 'Int8' isn't a type.
    final Pointer<Int8> blob = calloc<Int8>(length);
                                      ^^^^
: Error: 'Char' isn't a type.
    return blob.cast<Char>();
                     ^^^^
: Error: The getter 'nullptr' isn't defined for the class 'CodeResult'.
- 'CodeResult' is from 'package:flutter_zxing/generated_bindings.dart' ('../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_zxing-0.8.5/lib/generated_bindings.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'nullptr'.

      text == nullptr ? null : text.cast<Utf8>().toDartString();
              ^^^^^^^
: Error: 'Int8' isn't a type.
      Uint8List.fromList(bytes.cast<Int8>().asTypedList(length));
                                    ^^^^

: Error: The getter 'nullptr' isn't defined for the class 'EncodeResult'.
- 'EncodeResult' is from 'package:flutter_zxing/generated_bindings.dart' ('../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_zxing-0.8.5/lib/generated_bindings.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'nullptr'.

      text == nullptr ? null : text.cast<Utf8>().toDartString();
              ^^^^^^^
: Error: 'Int8' isn't a type.

      Uint32List.fromList(data.cast<Int8>().asTypedList(length));
                                    ^^^^
: Error: 'DynamicLibrary' isn't a type.
final DynamicLibrary stdlib = Platform.isWindows
      ^^^^^^^^^^^^^^
: Error: Undefined name 'DynamicLibrary'.
    ? DynamicLibrary.open('ole32.dll')
      ^^^^^^^^^^^^^^
: Error: Undefined name 'DynamicLibrary'.
    : DynamicLibrary.process();

      ^^^^^^^^^^^^^^
: Error: 'Pointer' isn't a type.
    Pointer<T> result;

    ^^^^^^^
: Error: 'Pointer' isn't a type.
  void free(Pointer pointer) {
            ^^^^^^^
: Error: 'Allocator' isn't a type.
const Allocator malloc = _MallocAllocator();
      ^^^^^^^^^
: Error: 'Pointer' isn't a type.
  void _fillMemory(Pointer destination, int length, int fill) {
                   ^^^^^^^
: Error: 'Uint8' isn't a type.
    final ptr = destination.cast<Uint8>();
                                 ^^^^^
: Error: 'Pointer' isn't a type.
  void _zeroMemory(Pointer destination, int length) =>
                   ^^^^^^^
: Error: 'Pointer' isn't a type.
    Pointer<T> result;
    ^^^^^^^
: Error: 'Pointer' isn't a type.
  void free(Pointer pointer) {
            ^^^^^^^
: Error: 'Allocator' isn't a type.
const Allocator calloc = _CallocAllocator();
      ^^^^^^^^^
: Error: 'Allocator' isn't a type.
  final Allocator _wrappedAllocator;
        ^^^^^^^^^
: Error: 'NativeType' isn't a type.
  final List<Pointer<NativeType>> _managedMemoryPointers = [];
                     ^^^^^^^^^^
: Error: 'Pointer' isn't a type.
  final List<Pointer<NativeType>> _managedMemoryPointers = [];
             ^^^^^^^

: Error: 'Allocator' isn't a type.
  Arena([Allocator allocator = calloc]) : _wrappedAllocator = allocator;
         ^^^^^^^^^
: Error: 'NativeType' isn't a type.
  void free(Pointer<NativeType> pointer) {}
                    ^^^^^^^^^^
: Error: 'Pointer' isn't a type.
  void free(Pointer<NativeType> pointer) {}
            ^^^^^^^
: Error: 'Allocator' isn't a type.
    [Allocator wrappedAllocator = calloc]) {
     ^^^^^^^^^
: Error: 'Allocator' isn't a type.
    [Allocator wrappedAllocator = calloc]) {
     ^^^^^^^^^
: Error: 'Uint8' isn't a type.
    final codeUnits = cast<Uint8>();
                           ^^^^^
: Error: 'Uint8' isn't a type.
    final codeUnits = cast<Uint8>();
                           ^^^^^

: Error: 'Uint8' isn't a type.
  static int _length(Pointer<Uint8> codeUnits) {
                             ^^^^^
: Error: 'Pointer' isn't a type.
  static int _length(Pointer<Uint8> codeUnits) {
                     ^^^^^^^
: Error: 'Allocator' isn't a type.
  Pointer<Utf8> toNativeUtf8({Allocator allocator = malloc}) {
                              ^^^^^^^^^
: Error: 'Uint8' isn't a type.
    final Pointer<Uint8> result = allocator<Uint8>(units.length + 1);
                  ^^^^^
: Error: 'Pointer' isn't a type.
    final Pointer<Uint8> result = allocator<Uint8>(units.length + 1);
          ^^^^^^^
: Error: 'Uint8' isn't a type.
    final Pointer<Uint8> result = allocator<Uint8>(units.length + 1);
                                            ^^^^^
: Error: 'Uint16' isn't a type.
    final codeUnits = cast<Uint16>();
                           ^^^^^^
: Error: 'Uint16' isn't a type.
    final codeUnits = cast<Uint16>();
                           ^^^^^^
: Error: 'Uint16' isn't a type.
  static String _toKnownLengthString(Pointer<Uint16> codeUnits, int length) =>
                                             ^^^^^^
: Error: 'Pointer' isn't a type.
  static String _toKnownLengthString(Pointer<Uint16> codeUnits, int length) =>

                                     ^^^^^^^
: Error: 'Uint16' isn't a type.

  static String _toUnknownLengthString(Pointer<Uint16> codeUnits) {
                                               ^^^^^^
: Error: 'Pointer' isn't a type.
  static String _toUnknownLengthString(Pointer<Uint16> codeUnits) {
                                       ^^^^^^^

: Error: 'Uint16' isn't a type.
  static int _length(Pointer<Uint16> codeUnits) {

                             ^^^^^^
: Error: 'Pointer' isn't a type.
  static int _length(Pointer<Uint16> codeUnits) {
                     ^^^^^^^
: Error: 'Allocator' isn't a type.
  Pointer<Utf16> toNativeUtf16({Allocator allocator = malloc}) {
                                ^^^^^^^^^
: Error: 'Uint16' isn't a type.
    final Pointer<Uint16> result = allocator<Uint16>(units.length + 1);
                  ^^^^^^
: Error: 'Pointer' isn't a type.
    final Pointer<Uint16> result = allocator<Uint16>(units.length + 1);
          ^^^^^^^
: Error: 'Uint16' isn't a type.
    final Pointer<Uint16> result = allocator<Uint16>(units.length + 1);
                                             ^^^^^^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int topLeftX;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int topLeftY;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int topRightX;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int topRightY;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int bottomLeftX;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int bottomLeftY;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int bottomRightX;

               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int bottomRightY;
               ^

: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int isValid;
               ^

: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external ffi.Pointer<ffi.Char> text;

                                 ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external ffi.Pointer<ffi.UnsignedChar> bytes;
                                         ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int length;
               ^
: Error: Only JS interop members may be 'external'.

Try removing the 'external' keyword or adding a JS interop annotation.
  external int format;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.

  external ffi.Pointer<Pos> pos;
                            ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int count;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external ffi.Pointer<CodeResult> results;
                                   ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int isValid;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external ffi.Pointer<ffi.Char> text;
                                 ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int format;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external ffi.Pointer<ffi.SignedChar> data;
                                       ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external int length;
               ^
: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
  external ffi.Pointer<ffi.Char> error;

                                 ^
Failed to compile application.
Exited
khoren93 commented 1 year ago

Hi there,

It is important to note that the dart:ffi package is not designed to be used with web-based Flutter applications, and attempting to use it may result in compilation errors or other issues.

If anyone has experience with the building dart:ffi package in Web to fix compile issues and might be able to offer some guidance, I would really appreciate it.

Thank you for your time and help.

Best regards, Khoren

r-ilagan commented 1 year ago

Is there a way to expose the library only when compiling for mobile?

khoren93 commented 1 year ago

@r-ilagan

I have released a new version v0.9.0 and would like to ask if you could please check if the issue still persists in the new version.

r-ilagan commented 1 year ago

Hi @khoren93 ,

I just tested out the new version and it works! Web is able to run perfectly. Thank you for the quick resolution! I also noticed a change in the onScan() parameter with CodeResult to Code. Perhaps it should be documented. Other than that, it's looking good on my end.

Thanks again!

khoren93 commented 1 year ago

I am closing this issue because it has been fixed in the latest version. Thanks for reporting the issue.