drawQRCode method

Future<void> drawQRCode(
  1. Canvas canvas,
  2. Size size,
  3. QrCode qrCode,
  4. Paint paint,
  5. double pixelSize,
)

Implementation

Future<void> drawQRCode(Canvas canvas, Size size, QrCode qrCode, Paint paint, double pixelSize) async {
  for (var x = 0; x < qrCode.moduleCount; x++) {
    for (var y = 0; y < qrCode.moduleCount; y++) {
      var isDark = QrImage(qrCode).isDark(y, x);

      if (isDark) {
        // Check if the current module is not overlapped by the image
        if (image == null || !isImagePixel(x, y, size)) {
          Rect rect = Rect.fromLTWH(x.toDouble() * pixelSize, y.toDouble() * pixelSize, pixelSize, pixelSize);
          canvas.drawRect(rect, paint);
        }
      }
    }
  }
}