Closed jeffreycool closed 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.
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, ), ); } }