skip to Main Content

I cannot figure out on how to convert a generated qr code by the use of QrImageView into a image file type that can be saved in the database

This is my code for generating a qr code:

Widget buildGenerateQrCode(){
    String qrData = '$docu_title, $docu_type, $docu_sender, $docu_recipient, $_selectedFile';
    return QrImageView(
        data: qrData,
        version: QrVersions.auto,
        size: 200.0,
    );
  }

2

Answers


  1. Use QrPainter class of the qr_flutter package.

        ByteData qrBytes = await QrPainter(
          data: "http://www.google.com",
          topLeftRadius: 10,
          bottomLeftRadius: 10,
          topRightRadius: 10,
          bottomRightRadius: 10,
          gapless: true,
          version: QrVersions.auto,
          color: Color.fromRGBO(0, 118, 191, 1),
          emptyColor: Colors.white,
        ).toImageData(878);
    

    You can do something with the image data, send it to database or save on disk.

    Source: https://github.com/theyakka/qr.flutter/issues/115

    Login or Signup to reply.
  2. Convert any UI widget to Image without package
    Creating raw image from Widget or Canvas
    and then save it local storage as file using dart:io and https://pub.dev/packages/path_provider

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search