fix:修复门铃码保存后是黑色图片问题
This commit is contained in:
parent
460ca1e2e2
commit
148541bcb2
@ -2,6 +2,7 @@ import 'dart:typed_data';
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
@ -54,7 +55,7 @@ class ShowCupertinoAlertView {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'${"开启微信接收报警消息需要先关注".tr}$qrCodeText${"微信公众号,请保存二维码并使用微信扫一扫设置".tr}',
|
'${"开启微信接收报警消息需要先关注".tr}$qrCodeText${"微信公众号,请保存二维码并使用微信扫一扫设置".tr}',
|
||||||
style:
|
style:
|
||||||
TextStyle(fontSize: 24.sp, color: Colors.black),
|
TextStyle(fontSize: 24.sp, color: Colors.black),
|
||||||
)),
|
)),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 60.h,
|
height: 60.h,
|
||||||
@ -159,8 +160,8 @@ class ShowCupertinoAlertView {
|
|||||||
//发送需要实名认证的电子钥匙时身份信息确认框
|
//发送需要实名认证的电子钥匙时身份信息确认框
|
||||||
void realNameIDCardInfoComfirmAlert(
|
void realNameIDCardInfoComfirmAlert(
|
||||||
{required String getNameStr,
|
{required String getNameStr,
|
||||||
required String getIDCardStr,
|
required String getIDCardStr,
|
||||||
required VoidCallback onConfirm}) {
|
required VoidCallback onConfirm}) {
|
||||||
showCupertinoDialog(
|
showCupertinoDialog(
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@ -340,7 +341,7 @@ class ShowCupertinoAlertView {
|
|||||||
),
|
),
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child:
|
child:
|
||||||
Text('购买'.tr, style: TextStyle(color: AppColors.mainColor)),
|
Text('购买'.tr, style: TextStyle(color: AppColors.mainColor)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
sureClick();
|
sureClick();
|
||||||
@ -391,7 +392,7 @@ class ShowCupertinoAlertView {
|
|||||||
),
|
),
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child:
|
child:
|
||||||
Text('删除'.tr, style: TextStyle(color: AppColors.mainColor)),
|
Text('删除'.tr, style: TextStyle(color: AppColors.mainColor)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
clearClick();
|
clearClick();
|
||||||
@ -406,8 +407,8 @@ class ShowCupertinoAlertView {
|
|||||||
//可视门铃二维码弹窗
|
//可视门铃二维码弹窗
|
||||||
void showVisualDoorbellCodeAlert(
|
void showVisualDoorbellCodeAlert(
|
||||||
{required BuildContext widgetContext,
|
{required BuildContext widgetContext,
|
||||||
required String qrCodeUrl,
|
required String qrCodeUrl,
|
||||||
required String qrCodeText}) {
|
required String qrCodeText}) {
|
||||||
showCupertinoModalPopup(
|
showCupertinoModalPopup(
|
||||||
context: widgetContext,
|
context: widgetContext,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -447,7 +448,7 @@ class ShowCupertinoAlertView {
|
|||||||
child: Text(
|
child: Text(
|
||||||
qrCodeText,
|
qrCodeText,
|
||||||
style:
|
style:
|
||||||
TextStyle(fontSize: 24.sp, color: Colors.black),
|
TextStyle(fontSize: 24.sp, color: Colors.black),
|
||||||
)),
|
)),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(left: 60.w, right: 60.w),
|
margin: EdgeInsets.only(left: 60.w, right: 60.w),
|
||||||
@ -456,29 +457,33 @@ class ShowCupertinoAlertView {
|
|||||||
onClick: () async {
|
onClick: () async {
|
||||||
// 截图并保存到相册
|
// 截图并保存到相册
|
||||||
try {
|
try {
|
||||||
|
final Color qrcodeStyleColor =
|
||||||
|
defaultTargetPlatform == TargetPlatform.iOS
|
||||||
|
? const Color(0xFF000000)
|
||||||
|
: Colors.white;
|
||||||
final QrPainter painter = QrPainter(
|
final QrPainter painter = QrPainter(
|
||||||
data: qrCodeUrl,
|
data: qrCodeUrl,
|
||||||
version: QrVersions.auto,
|
version: QrVersions.auto,
|
||||||
gapless: false,
|
gapless: false,
|
||||||
errorCorrectionLevel: QrErrorCorrectLevel.L,
|
errorCorrectionLevel: QrErrorCorrectLevel.L,
|
||||||
eyeStyle: const QrEyeStyle(
|
eyeStyle: QrEyeStyle(
|
||||||
eyeShape: QrEyeShape.square,
|
eyeShape: QrEyeShape.square,
|
||||||
color: Colors.white,
|
color: qrcodeStyleColor,
|
||||||
),
|
),
|
||||||
dataModuleStyle: const QrDataModuleStyle(
|
dataModuleStyle: QrDataModuleStyle(
|
||||||
dataModuleShape: QrDataModuleShape.square,
|
dataModuleShape: QrDataModuleShape.square,
|
||||||
color: Colors.white,
|
color: qrcodeStyleColor,
|
||||||
));
|
));
|
||||||
final ByteData? byteData =
|
final ByteData? byteData =
|
||||||
await painter.toImageData(600.0,
|
await painter.toImageData(600.0,
|
||||||
format: ImageByteFormat.png);
|
format: ImageByteFormat.png);
|
||||||
final Uint8List pngBytes =
|
final Uint8List pngBytes =
|
||||||
byteData!.buffer.asUint8List();
|
byteData!.buffer.asUint8List();
|
||||||
final result =
|
final result =
|
||||||
await ImageGallerySaver.saveImage(
|
await ImageGallerySaver.saveImage(
|
||||||
Uint8List.fromList(pngBytes),
|
Uint8List.fromList(pngBytes),
|
||||||
quality: 100,
|
quality: 100,
|
||||||
name: 'qr_code');
|
name: 'qr_code');
|
||||||
if (result['isSuccess']) {
|
if (result['isSuccess']) {
|
||||||
EasyLoading.showToast('保存成功'.tr);
|
EasyLoading.showToast('保存成功'.tr);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user