theyakka / qr.flutter

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.
https://pub.dev/packages/qr_flutter
BSD 3-Clause "New" or "Revised" License
718 stars 323 forks source link

emptyColor #210

Open jcarvalhogo opened 1 year ago

jcarvalhogo commented 1 year ago

Hi theyakka, I'm using your lib to generate qrcode, I'm using the QrPainter class to create the qrcode and getting the BufferByte to save it to file.

I have the following problem, if I don't use emptyColor the saved image has a black background.

Code: image

image

Code: image image

however the emptyColor attribute is deprecated, what alternatives do I have to replace the emptyColor attribute while maintaining the same result?

I am grateful in advance for your attention

DuffyHomer commented 1 year ago

Sorry for respond late.

I see you're using the QrPainter class to generate QR codes in your Flutter code. To replace the deprecated emptyColor attribute, you can use the color attribute instead, which sets the color of the QR code itself. If you want to make the QR code have a white background, you can set the color attribute to white. Here's how you can update your code:

On Sun, Sep 24, 2023 at 3:35 AM Jose Josemar de Carvalho < @.***> wrote:

Hi theyakka, I'm using your lib to generate qrcode, I'm using the QrPainter class to create the qrcode and getting the BufferByte to save it to file.

I have the following problem, if I don't use emptyColor the saved image has a black background.

Code: [image: image] https://user-images.githubusercontent.com/5593817/270143097-dbee2d2e-4220-434f-9d76-c7c514df8909.png

[image: image] https://user-images.githubusercontent.com/5593817/270142889-57e5564a-f625-4d03-9d75-87acaad8cea2.png

Code: [image: image] https://user-images.githubusercontent.com/5593817/270143019-0248ad50-e14a-427a-a9c6-e9c402818d8c.png [image: image] https://user-images.githubusercontent.com/5593817/270143147-ff1932e2-4c9e-4452-a21c-2a5a5999e10e.png

however the emptyColor attribute is deprecated, what alternatives do I have to replace the emptyColor attribute while maintaining the same result?

I am grateful in advance for your attention

— Reply to this email directly, view it on GitHub https://github.com/theyakka/qr.flutter/issues/210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVAU5BV3FAFFJSFTZO4SPS3X36TAJANCNFSM6AAAAAA5EUQRSU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

RobotBroer commented 1 year ago

I would also like to understand what is the alternative. The 'color' property is also deprecated, the suggestion in the code: @Deprecated( 'You should use the background color value of your container widget', ) this.emptyColor,

The problem with this is that I am generating an Image and not a widget, I would like to have a white background on my png image, or a png without the alpha channel. How can I achieve this without emptyColor?

2Math0 commented 1 year ago

I faced the same issue and I was going to open an issue here but found this one is already opened @RobotBroer and @jcarvalhogo here both show the issue in a good way, but why not share it again!

Mainly we use QR code to share some links. In a lot of scenarios, we need to share or save the QR code as an image. the issue happens because the paint canvas in QrPainter() widget is transparent then it paints the pixels and leaves empty cells transparent

when user try to share qr code like in WhatsApp for example, the user will get blank black screen which actually black pixels of QR code and black canvas of WhatsApp so the QR code becomes Invisible

let me send the code that is Working:

final image = await QrPainter(
      // ignore: deprecated_member_use
      emptyColor: Colors.white,
      data: await buildQrLink(tableId),
      version: QrVersions.auto,
      gapless: false,
    ).toImage(300);

This image will always show QR code with black pixels and tints with a white background (not a blank black Image)

so I suggest getting emptyColor property back again or giving a more reliable solution of such a situation if there is a solution that needs time to be coded tell me about I will be very happy to participate.

denysbohatyrov commented 7 months ago

Same issue