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

App crash when width/height are too bigger in encodeBarcode() #100

Open
romgrm opened this issue Jul 18, 2023 · 0 comments
Open

App crash when width/height are too bigger in encodeBarcode() #100

romgrm opened this issue Jul 18, 2023 · 0 comments

Comments

@romgrm
Copy link

romgrm commented Jul 18, 2023

Hello :)

I want to generate a barcode in aztec format.
So I use the encodeBarcode() method, to which I send the data and set the parameters.
The default width/height (120px) doesn't work for me, so I increase it.

class BarcodeGeneratorService implements BarcodeGeneratorInterface {
  final Zxing _barcodeGenerator;

  BarcodeGeneratorService({Zxing? flutterZxing}) : _barcodeGenerator = flutterZxing ?? Zxing();
  @override
  Uint8List? encode({
    required String textToEncode,
    required int format,
    required int width,
    required int height,
    required int margin,
  }) {
    final encoded = _barcodeGenerator.encodeBarcode(
        contents: textToEncode,
        params: EncodeParams(format: Format.aztec,  width: 150, height: 150 , eccLevel: EccLevel.high));

    if (!encoded.isValid || encoded.data == null) {
      return null;
    }
    final imglib.Image img = imglib.Image.fromBytes(
      150,
      150,
      encoded.data!,
    );
    return Uint8List.fromList(
      imglib.encodeJpg(img),
    );
  }
}

When I want to display my barcode, when the encodeBarcode() method is triggered, my application crashes at this point.

The crash occurs on several physical iOS devices, in 16 and 16.5.
On the other hand, everything works fine on simulator.

The error is not very clear:

image

Do you have any idea what it could be?

Thanks :)

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

No branches or pull requests

1 participant