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

The content of the successful QR code cannot be scanned using the scan plugin #185

Closed jeffreycool closed 2 years ago

jeffreycool commented 2 years ago

Hello, after I use embeddedImage to overlay the center image (the image size is 80*80, and the size of the QR code is 300), I cannot scan the content of the QR code successfully using the scan plugin. code: import 'package:hongli/base_common/base_core.dart'; import 'package:hongli/base_common/get_core.dart'; import 'package:mrk_shopping_mall/res/strings.dart'; import 'package:flutter/widgets.dart'; import 'package:qr_flutter/qr_flutter.dart';

class QrWidget extends StatelessWidget { final String data; final double size;

//中心图片来源,true为网络,false为本地资源 final bool? fromUrl;

//中间图片 final String? url;

//中间图片的尺寸 final Size? imageSize; const QrWidget( {Key? key, required this.data, required this.size, this.fromUrl, this.url, this.imageSize=const Size(60,60)}) : super(key: key);

@override Widget build(BuildContext context) { return url != null&&url!.isNotEmpty?( fromUrl??false?QrImage( data: data, version: QrVersions.auto, size: size, gapless: false, errorStateBuilder: (cxt, err) { return errorBuild(); }, embeddedImage: NetworkImage(url!), embeddedImageStyle: QrEmbeddedImageStyle(size: imageSize), ):QrImage( data: data, version: QrVersions.auto, size: size, gapless: false, errorStateBuilder: (cxt, err) { return errorBuild(); }, embeddedImage: AssetImage(ImageUtils.getImagePath(url!)), embeddedImageStyle: QrEmbeddedImageStyle(size: imageSize), ) ):QrImage( data: data, version: QrVersions.auto, size: size, gapless: false, errorStateBuilder: (cxt, err) { return errorBuild(); }, ); }

Widget errorBuild(){ return Center( child: Text( Ids.qrShowErrorText.tr, textAlign: TextAlign.center, ), ); } }

lukef commented 2 years ago

This has nothing to do with the library is is related to the configuration you're using to generate the QR code. You should try to use a higher QR code version or a higher level of error correction if you're obscuring a larger portion of the QR code with an image.