fix:修复门铃码保存后是黑色图片问题

This commit is contained in:
Liuyf 2025-02-19 11:52:38 +08:00
parent b9fb2bd479
commit 460ca1e2e2

View File

@ -456,16 +456,24 @@ class ShowCupertinoAlertView {
onClick: () async {
//
try {
final RenderRepaintBoundary boundary =
_repaintBoundaryKey.currentContext!
.findRenderObject()!
as RenderRepaintBoundary;
final image = await boundary.toImage();
final ByteData? byteData = await image
.toByteData(format: ImageByteFormat.png);
final QrPainter painter = QrPainter(
data: qrCodeUrl,
version: QrVersions.auto,
gapless: false,
errorCorrectionLevel: QrErrorCorrectLevel.L,
eyeStyle: const QrEyeStyle(
eyeShape: QrEyeShape.square,
color: Colors.white,
),
dataModuleStyle: const QrDataModuleStyle(
dataModuleShape: QrDataModuleShape.square,
color: Colors.white,
));
final ByteData? byteData =
await painter.toImageData(600.0,
format: ImageByteFormat.png);
final Uint8List pngBytes =
byteData!.buffer.asUint8List();
final result =
await ImageGallerySaver.saveImage(
Uint8List.fromList(pngBytes),