qr.flutter
qr.flutter copied to clipboard
The argument type 'Image' can't be assigned to the parameter type 'Image?'.
I am trying to export a QR code with an embedded image but I am not able to do that because it doesn't accept any type of image. I have tried literally every type of image possible still it just won't accept. What does it want?
Error:
My Code:
final painter = QrPainter.withQr(
qr: qrCode!,
color: const Color(0xFF000000),
gapless: true,
embeddedImageStyle: null,
embeddedImage: Image(image: null,)
);
Use AssetImage or NetworkImage.
Use AssetImage or NetworkImage.
Already tried, they give the same error.
Show your code when using my above suggestion.
I know I have to enter image URL in NetworkImage, I just did for testing and to show you.
Oh you're using QrPainter, not QrImageView. Is that intentional?
QrPainter expects a type of Image from dart:ui, not flutter/widgets.
Oh you're using QrPainter, not QrImageView. Is that intentional?
Yes, I need an Embedded image when exporting the QR Code.
QrPainter expects a type of Image from dart:ui, not flutter/widgets.
So, what should I do to give it an Embedded image when exporting the QR ?
@lukef Can you convert this issue to discussion?
So, what should I do to give it an image when exporting the QR ?
https://pub.dev/packages/flutter_svg_provider
@itss-sid I just had the same problem and found the solution in the example of this package. Here is my code, to solve it:
import 'dart:ui' as ui;
import 'dart:async';
final completer = Completer<ui.Image>();
final byteData = await rootBundle.load('assets/images/icon.png');
ui.decodeImageFromList(byteData.buffer.asUint8List(), completer.complete);
completer.future.then((embeddedImage) {
QrPainter.withQr(
qr: qr,
embeddedImage: embeddedImage,
);
});