How do we download QR code from Flutter Web?

How do we download QR code from Flutter Web?

Solution :
The path provider does not allow to download  a QR code and it has limitations in Flutter Web so here’s the solution for your query

downloadQR(String data) async {
final qrValidationResult =
QrValidator.validate(
data: data,
version: QrVersions.auto,
errorCorrectionLevel: QrErrorCorrectLevel.L,
);
final qrCode = qrValidationResult.qrCode; final image = await QrPainter.withQr(
qr: qrCode!,
color: const Color(0xFF000000),
gapless: true,
embeddedImageStyle: null,
embeddedImage: null,
).toImageData(1000); var pngBytes = image!.buffer.asUint8List(); var download = document.createElement(‘a’)
as AnchorElement; download.href =
‘data:image/png;base64,${base64Encode(pngBytes)}’;
download.download = ‘qr_code.png’; download.click();
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *



×

    Request a Proposal

    Fill Out Our Form & We’ll be in Touch Shortly

    Type of Project



    Our Locations

    PH: +1-202-938-5932

    USA

    10630 Little Patuxent Pkwy,
    Suite 314-M7
    Columbia, MD 21044

    UK

    120 Bark Street
    6th & 7th Floor
    Bolton Lancashire, United Kingdom Bl12ax

    Australia

    443 Camp Rd, Broadmeadows
    VIC, Australia