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 { onClick: () async {
// //
try { try {
final RenderRepaintBoundary boundary = final QrPainter painter = QrPainter(
_repaintBoundaryKey.currentContext! data: qrCodeUrl,
.findRenderObject()! version: QrVersions.auto,
as RenderRepaintBoundary; gapless: false,
final image = await boundary.toImage(); errorCorrectionLevel: QrErrorCorrectLevel.L,
final ByteData? byteData = await image eyeStyle: const QrEyeStyle(
.toByteData(format: ImageByteFormat.png); 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 = 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),
@ -498,113 +506,113 @@ class ShowCupertinoAlertView {
); );
} }
// // // //
// void emailNotifyTypeSlectAlert() { // void emailNotifyTypeSlectAlert() {
// showCupertinoDialog( // showCupertinoDialog(
// context: Get.context!, // context: Get.context!,
// builder: (BuildContext context) { // builder: (BuildContext context) {
// return CupertinoAlertDialog( // return CupertinoAlertDialog(
// title: const Text('类型选择'), // title: const Text('类型选择'),
// content: Column( // content: Column(
// children: <Widget>[ // children: <Widget>[
// Padding( // Padding(
// padding: EdgeInsets.only( // padding: EdgeInsets.only(
// left: 10.w, top: 8.h, bottom: 16.h, right: 10.w), // left: 10.w, top: 8.h, bottom: 16.h, right: 10.w),
// child: Align( // child: Align(
// alignment: Alignment.centerLeft, // alignment: Alignment.centerLeft,
// child: Text('请选择要使用哪种类型', style: TextStyle(fontSize: 20.sp)), // child: Text('请选择要使用哪种类型', style: TextStyle(fontSize: 20.sp)),
// ), // ),
// ), // ),
// GestureDetector( // GestureDetector(
// onTap: () { // onTap: () {
// setState(() { // setState(() {
// isSystemEmailSelected = true; // isSystemEmailSelected = true;
// }); // });
// }, // },
// child: Row( // child: Row(
// mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[ // children: <Widget>[
// Image.asset( // Image.asset(
// isSystemEmailSelected // isSystemEmailSelected
// ? 'images/icon_round_select.png' // ? 'images/icon_round_select.png'
// : 'images/icon_round_unSelect.png', // : 'images/icon_round_unSelect.png',
// width: 30.w, // width: 30.w,
// height: 30.w, // height: 30.w,
// ), // ),
// Padding( // Padding(
// padding: EdgeInsets.only(left: 10.w), // padding: EdgeInsets.only(left: 10.w),
// child: Text( // child: Text(
// '系统邮件(推荐)', // '系统邮件(推荐)',
// style: TextStyle( // style: TextStyle(
// fontSize: 22.sp, fontWeight: FontWeight.bold), // fontSize: 22.sp, fontWeight: FontWeight.bold),
// ), // ),
// ), // ),
// ], // ],
// ), // ),
// ), // ),
// Padding( // Padding(
// padding: EdgeInsets.only(top: 6.h, left: 10.w, bottom: 10.h), // padding: EdgeInsets.only(top: 6.h, left: 10.w, bottom: 10.h),
// child: Align( // child: Align(
// alignment: Alignment.centerLeft, // alignment: Alignment.centerLeft,
// child: Text( // child: Text(
// '邮件将从软件平台直接发给用户,请根据需要在软件那里购买邮件数量', // '邮件将从软件平台直接发给用户,请根据需要在软件那里购买邮件数量',
// style: TextStyle(fontSize: 18.sp), // style: TextStyle(fontSize: 18.sp),
// textAlign: TextAlign.left, // textAlign: TextAlign.left,
// ), // ),
// ), // ),
// ), // ),
// GestureDetector( // GestureDetector(
// onTap: () { // onTap: () {
// setState(() { // setState(() {
// isSystemEmailSelected = false; // isSystemEmailSelected = false;
// }); // });
// }, // },
// child: Row( // child: Row(
// mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[ // children: <Widget>[
// Image.asset( // Image.asset(
// !isSystemEmailSelected // !isSystemEmailSelected
// ? 'images/icon_round_select.png' // ? 'images/icon_round_select.png'
// : 'images/icon_round_unSelect.png', // : 'images/icon_round_unSelect.png',
// width: 30.w, // width: 30.w,
// height: 30.w, // height: 30.w,
// ), // ),
// Padding( // Padding(
// padding: EdgeInsets.only(left: 10.w), // padding: EdgeInsets.only(left: 10.w),
// child: Text( // child: Text(
// '个人邮件', // '个人邮件',
// style: TextStyle( // style: TextStyle(
// fontSize: 22.sp, fontWeight: FontWeight.bold), // fontSize: 22.sp, fontWeight: FontWeight.bold),
// ), // ),
// ), // ),
// ], // ],
// ), // ),
// ), // ),
// Padding( // Padding(
// padding: EdgeInsets.only(top: 6.h, left: 10.w), // padding: EdgeInsets.only(top: 6.h, left: 10.w),
// child: Align( // child: Align(
// alignment: Alignment.centerLeft, // alignment: Alignment.centerLeft,
// child: Text( // child: Text(
// '邮件将从你的个人邮箱发给用户', // '邮件将从你的个人邮箱发给用户',
// style: TextStyle(fontSize: 18.sp), // style: TextStyle(fontSize: 18.sp),
// ), // ),
// ), // ),
// ), // ),
// ], // ],
// ), // ),
// actions: <Widget>[ // actions: <Widget>[
// CupertinoDialogAction( // CupertinoDialogAction(
// onPressed: Get.back, // onPressed: Get.back,
// child: Text( // child: Text(
// '确定'.tr, // '确定'.tr,
// style: TextStyle(color: AppColors.mainColor), // style: TextStyle(color: AppColors.mainColor),
// ), // ),
// ), // ),
// ], // ],
// ); // );
// }, // },
// ); // );
// } // }
} }