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

The argument type 'Image' can't be assigned to the parameter type 'Image?'. #181

Open
itss-sid opened this issue Jun 14, 2022 · 12 comments
Open

Comments

@itss-sid
Copy link

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:
image

My Code:

final painter = QrPainter.withQr(
        qr: qrCode!,
        color: const Color(0xFF000000),
        gapless: true,
        embeddedImageStyle: null,
        embeddedImage: Image(image: null,)
      );
@noga-dev
Copy link

noga-dev commented Jul 4, 2022

Use AssetImage or NetworkImage.

@itss-sid
Copy link
Author

itss-sid commented Jul 5, 2022

Use AssetImage or NetworkImage.

Already tried, they give the same error.

@noga-dev
Copy link

noga-dev commented Jul 5, 2022

Show your code when using my above suggestion.

@itss-sid
Copy link
Author

itss-sid commented Jul 5, 2022

image

@itss-sid
Copy link
Author

itss-sid commented Jul 5, 2022

image

@itss-sid
Copy link
Author

itss-sid commented Jul 5, 2022

I know I have to enter image URL in NetworkImage, I just did for testing and to show you.

@noga-dev
Copy link

noga-dev commented Jul 5, 2022

Oh you're using QrPainter, not QrImageView. Is that intentional?

@noga-dev
Copy link

noga-dev commented Jul 5, 2022

QrPainter expects a type of Image from dart:ui, not flutter/widgets.

@itss-sid
Copy link
Author

itss-sid commented Jul 5, 2022

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 ?

@noga-dev
Copy link

@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

@aklehm
Copy link

aklehm commented Mar 22, 2023

@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,
       
      );
    });

@abdullahalamodi
Copy link

@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,
       
      );
    });

this should be done under the hood 😖

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

4 participants