|
@@ -56,17 +56,13 @@ import 'dart:typed_data'; |
|
@@ -56,17 +56,13 @@ import 'dart:typed_data'; |
|
56
|
typedef BookTimeSetCallback = void Function(bool needChange);
|
56
|
typedef BookTimeSetCallback = void Function(bool needChange);
|
|
57
|
|
57
|
|
|
58
|
class Utils {
|
58
|
class Utils {
|
|
59
|
-
|
|
|
|
60
|
-
|
|
|
|
61
|
-
|
|
|
|
62
|
-
|
|
|
|
63
|
-static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async {
|
|
|
|
64
|
- if(imageBytes == null ){
|
|
|
|
65
|
- return false;
|
59
|
+ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async {
|
|
|
|
60
|
+ if (imageBytes == null) {
|
|
|
|
61
|
+ return false;
|
|
|
|
62
|
+ }
|
|
|
|
63
|
+ var fileSize = imageBytes.lengthInBytes;
|
|
|
|
64
|
+ return fileSize > 64 * 1024; // 64KB = 64 * 1024 bytes
|
|
66
|
}
|
65
|
}
|
|
67
|
- var fileSize = imageBytes.lengthInBytes;
|
|
|
|
68
|
- return fileSize > 64 * 1024; // 64KB = 64 * 1024 bytes
|
|
|
|
69
|
-}
|
|
|
|
70
|
|
66
|
|
|
71
|
static List<CallLogEntry> removeDuplicates(List<CallLogEntry> items) {
|
67
|
static List<CallLogEntry> removeDuplicates(List<CallLogEntry> items) {
|
|
72
|
List<CallLogEntry> uniqueItems = []; // uniqueList
|
68
|
List<CallLogEntry> uniqueItems = []; // uniqueList
|
|
@@ -1459,8 +1455,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -1459,8 +1455,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
1459
|
Uint8List? result;
|
1455
|
Uint8List? result;
|
|
1460
|
|
1456
|
|
|
1461
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
1457
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
1462
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
1463
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
1458
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
1459
|
+ result = resultnew == null
|
|
|
|
1460
|
+ ? null
|
|
|
|
1461
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
1464
|
}
|
1462
|
}
|
|
1465
|
var model = new WeChatShareMiniProgramModel(
|
1463
|
var model = new WeChatShareMiniProgramModel(
|
|
1466
|
miniProgramType: Constant.wxMiniProgramType,
|
1464
|
miniProgramType: Constant.wxMiniProgramType,
|
|
@@ -1504,8 +1502,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -1504,8 +1502,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
1504
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
1502
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
1505
|
Uint8List? result;
|
1503
|
Uint8List? result;
|
|
1506
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
1504
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
1507
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
1508
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
1505
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
1506
|
+ result = resultnew == null
|
|
|
|
1507
|
+ ? null
|
|
|
|
1508
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
1509
|
}
|
1509
|
}
|
|
1510
|
var model = new WeChatShareMiniProgramModel(
|
1510
|
var model = new WeChatShareMiniProgramModel(
|
|
1511
|
// miniProgramType: , //体验版
|
1511
|
// miniProgramType: , //体验版
|
|
@@ -1596,9 +1596,11 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -1596,9 +1596,11 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
1596
|
Fluwx fluwx = Fluwx();
|
1596
|
Fluwx fluwx = Fluwx();
|
|
1597
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
1597
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
1598
|
Uint8List? result;
|
1598
|
Uint8List? result;
|
|
1599
|
- if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
|
|
1600
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
1601
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
1599
|
+ if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
|
|
1600
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
1601
|
+ result = resultnew == null
|
|
|
|
1602
|
+ ? null
|
|
|
|
1603
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
1602
|
}
|
1604
|
}
|
|
1603
|
var model = new WeChatShareMiniProgramModel(
|
1605
|
var model = new WeChatShareMiniProgramModel(
|
|
1604
|
miniProgramType: Constant.wxMiniProgramType,
|
1606
|
miniProgramType: Constant.wxMiniProgramType,
|
|
@@ -2028,8 +2030,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2028,8 +2030,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2028
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
2030
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
2029
|
Uint8List? result;
|
2031
|
Uint8List? result;
|
|
2030
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
2032
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
2031
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
2032
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
2033
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
2034
|
+ result = resultnew == null
|
|
|
|
2035
|
+ ? null
|
|
|
|
2036
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
2033
|
}
|
2037
|
}
|
|
2034
|
|
2038
|
|
|
2035
|
//跳转小程序
|
2039
|
//跳转小程序
|
|
@@ -2087,9 +2091,11 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2087,9 +2091,11 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2087
|
// Uint8List source = await testComporessList(context, _thumbnail);
|
2091
|
// Uint8List source = await testComporessList(context, _thumbnail);
|
|
2088
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
2092
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
2089
|
Uint8List? result;
|
2093
|
Uint8List? result;
|
|
2090
|
- if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
|
|
2091
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
2092
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
2094
|
+ if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
|
|
2095
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
2096
|
+ result = resultnew == null
|
|
|
|
2097
|
+ ? null
|
|
|
|
2098
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
2093
|
}
|
2099
|
}
|
|
2094
|
//跳转小程序
|
2100
|
//跳转小程序
|
|
2095
|
Fluwx fluwx = Fluwx();
|
2101
|
Fluwx fluwx = Fluwx();
|
|
@@ -2192,8 +2198,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2192,8 +2198,10 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2192
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
2198
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
2193
|
Uint8List? result;
|
2199
|
Uint8List? result;
|
|
2194
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
2200
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
2195
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
2196
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
2201
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
2202
|
+ result = resultnew == null
|
|
|
|
2203
|
+ ? null
|
|
|
|
2204
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
2197
|
}
|
2205
|
}
|
|
2198
|
// print(result!.length/1024);
|
2206
|
// print(result!.length/1024);
|
|
2199
|
//跳转小程序
|
2207
|
//跳转小程序
|
|
@@ -2256,9 +2264,11 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2256,9 +2264,11 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2256
|
Fluwx fluwx = Fluwx();
|
2264
|
Fluwx fluwx = Fluwx();
|
|
2257
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
2265
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
2258
|
Uint8List? result;
|
2266
|
Uint8List? result;
|
|
2259
|
- if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
|
|
2260
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
2261
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
2267
|
+ if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
|
|
2268
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
2269
|
+ result = resultnew == null
|
|
|
|
2270
|
+ ? null
|
|
|
|
2271
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
2262
|
}
|
2272
|
}
|
|
2263
|
var model = new WeChatShareMiniProgramModel(
|
2273
|
var model = new WeChatShareMiniProgramModel(
|
|
2264
|
webPageUrl: _webPageUrl,
|
2274
|
webPageUrl: _webPageUrl,
|
|
@@ -2432,39 +2442,485 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2432,39 +2442,485 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2432
|
// Uint8List result = await testFromFileComporessList(context, pngBytes);
|
2442
|
// Uint8List result = await testFromFileComporessList(context, pngBytes);
|
|
2433
|
// return result;
|
2443
|
// return result;
|
|
2434
|
// }
|
2444
|
// }
|
|
|
|
2445
|
+ static String returnWeek(DateTime day, BuildContext context) {
|
|
|
|
2446
|
+ String date = "周${Utils.formatWeekDayNum(day.weekday)} ";
|
|
2435
|
|
2447
|
|
|
2436
|
- static Future<Uint8List> canvas(
|
|
|
|
2437
|
- context, String _thumbnail, String month, String week) async {
|
2448
|
+ return date;
|
|
|
|
2449
|
+ }
|
|
|
|
2450
|
+
|
|
|
|
2451
|
+ static Future<Uint8List> canvas(context, String _thumbnail, DateTime date,
|
|
|
|
2452
|
+ String liteStyle, String dsolt, String ddateHm) async {
|
|
2438
|
var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
2453
|
var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
2439
|
var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
2454
|
var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
2440
|
var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
2455
|
var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
|
2441
|
print(images);
|
2456
|
print(images);
|
|
2442
|
- // Paint _linePaint = new Paint()
|
|
|
|
2443
|
- // ..color = Colors.blue
|
|
|
|
2444
|
- // ..style = PaintingStyle.fill
|
|
|
|
2445
|
- // ..isAntiAlias = true
|
|
|
|
2446
|
- // ..strokeCap = StrokeCap.round
|
|
|
|
2447
|
- // ..strokeWidth = 500;
|
|
|
|
2448
|
- // Paint selfPaint = Paint()
|
|
|
|
2449
|
- // ..color = Colors.red
|
|
|
|
2450
|
- // ..style = PaintingStyle.fill
|
|
|
|
2451
|
- // ..isAntiAlias = true
|
|
|
|
2452
|
- // ..strokeCap = StrokeCap.butt
|
|
|
|
2453
|
- // ..strokeWidth = 2;
|
|
|
|
2454
|
- Paint paint = Paint()
|
|
|
|
2455
|
- ..color = Color.fromRGBO(81, 81, 81, 0.4)
|
|
|
|
2456
|
- ..style = PaintingStyle.fill;
|
2457
|
+ final Paint paint = Paint();
|
|
|
|
2458
|
+ canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
|
|
|
|
2459
|
+
|
|
|
|
2460
|
+ List<String> subType = liteStyle.split('-');
|
|
|
|
2461
|
+ // String subType0 = subType[0]; //几号模版
|
|
|
|
2462
|
+ String subType1 = subType[1]; //模版下面的子样式
|
|
|
|
2463
|
+ String month =
|
|
|
|
2464
|
+ '${Utils.addZeroNumber(date.month)}月${Utils.addZeroNumber(date.day)}日 ';
|
|
|
|
2465
|
+ String week = returnWeek(date, context);
|
|
|
|
2466
|
+ String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm} ' : '';
|
|
|
|
2467
|
+ String section = subType1 == '1' || subType1 == '4'
|
|
|
|
2468
|
+ ? _getDsoltStrShow(dsolt)
|
|
|
|
2469
|
+ : subType1 == '2'
|
|
|
|
2470
|
+ ? _getDsoltStrShow(dsolt, isCan: false)
|
|
|
|
2471
|
+ : '';
|
|
|
|
2472
|
+
|
|
|
|
2473
|
+ String time = month + week + hour + section;
|
|
|
|
2474
|
+
|
|
|
|
2475
|
+ paint.color = MyColours.color_99000000;
|
|
|
|
2476
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2477
|
+ if (Platform.isIOS) {
|
|
|
|
2478
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2479
|
+ }
|
|
|
|
2480
|
+ // 定义源矩形,通常是图像的全部
|
|
|
|
2481
|
+ // final Rect source = Rect.fromLTWH(
|
|
|
|
2482
|
+ // 0.0, 0.0, images.width.toDouble(), images.height.toDouble());
|
|
|
|
2483
|
+ // // 定义目标矩形,即画布的大小
|
|
|
|
2484
|
+ // final Rect destination = Rect.fromLTWH(0.0, 0.0, w(210), w(168));
|
|
|
|
2485
|
+ // // 绘制图像
|
|
|
|
2486
|
+ canvas.drawRect(Rect.fromLTWH(0, 0, 500, 52), paint);
|
|
|
|
2487
|
+ // canvas.drawImageRect(images, source, destination, paint);
|
|
|
|
2488
|
+
|
|
|
|
2489
|
+ // 定义源矩形,通常是图像的全部
|
|
|
|
2490
|
+ // final Rect source2 = Rect.fromLTWH(
|
|
|
|
2491
|
+ // 0.0, w(142), images.width.toDouble(), images.height.toDouble());
|
|
|
|
2492
|
+ // // 定义目标矩形,即画布的大小
|
|
|
|
2493
|
+ // final Rect destination2 = Rect.fromLTWH(0.0, 0.0, 500, 400);
|
|
|
|
2494
|
+ // // 绘制图像
|
|
|
|
2495
|
+ // canvas.drawImageRect(images, source2, destination2, paint);
|
|
|
|
2496
|
+ if (Platform.isIOS) {
|
|
|
|
2497
|
+ final paint1 = Paint()
|
|
|
|
2498
|
+ ..color = MyColours.color_99000000
|
|
|
|
2499
|
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
|
|
|
2500
|
+ ..style = PaintingStyle.fill;
|
|
|
|
2501
|
+ // 绘制一个矩形作为蒙版
|
|
|
|
2502
|
+ canvas.drawRect(Rect.fromLTRB(0, 0, 500, 400), paint1);
|
|
|
|
2503
|
+ }
|
|
|
|
2504
|
+ // 绘制文字
|
|
|
|
2505
|
+ ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2506
|
+ textAlign: TextAlign.center,
|
|
|
|
2507
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2508
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2509
|
+ maxLines: 1,
|
|
|
|
2510
|
+ ellipsis: '3',
|
|
|
|
2511
|
+ fontSize: 24));
|
|
|
|
2512
|
+ pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 24));
|
|
|
|
2513
|
+ pb2.addText(
|
|
|
|
2514
|
+ '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
|
|
|
|
2515
|
+
|
|
|
|
2516
|
+ // 设置文本的宽度约束
|
|
|
|
2517
|
+ ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500);
|
|
|
|
2518
|
+ ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
|
|
|
|
2519
|
+ canvas.drawParagraph(paragraph2, Offset(0, 12));
|
|
|
|
2520
|
+
|
|
|
|
2521
|
+ canvas.drawRect(Rect.fromLTWH(0, 348, 500, 52), paint);
|
|
|
|
2522
|
+
|
|
|
|
2523
|
+ // 绘制文字
|
|
|
|
2524
|
+ ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2525
|
+ textAlign: TextAlign.center,
|
|
|
|
2526
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2527
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2528
|
+ fontSize: 24));
|
|
|
|
2529
|
+ pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 24));
|
|
|
|
2530
|
+ pb.addText(time);
|
|
|
|
2531
|
+
|
|
|
|
2532
|
+ // 设置文本的宽度约束
|
|
|
|
2533
|
+ ParagraphConstraints pc = ui.ParagraphConstraints(width: 500);
|
|
|
|
2534
|
+ ui.Paragraph paragraph = pb.build()..layout(pc);
|
|
|
|
2535
|
+ canvas.drawParagraph(paragraph, Offset(0, 360));
|
|
|
|
2536
|
+
|
|
|
|
2537
|
+ // 绘制文字
|
|
|
|
2538
|
+ // ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2539
|
+ // textAlign: TextAlign.center,
|
|
|
|
2540
|
+ // fontWeight: FontWeight.bold,
|
|
|
|
2541
|
+ // fontStyle: FontStyle.normal,
|
|
|
|
2542
|
+ // fontSize: 42));
|
|
|
|
2543
|
+ // pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 42));
|
|
|
|
2544
|
+ // pb3.addText(week);
|
|
|
|
2545
|
+
|
|
|
|
2546
|
+ // // 设置文本的宽度约束
|
|
|
|
2547
|
+ // ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 500);
|
|
|
|
2548
|
+ // ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
|
|
|
|
2549
|
+ // canvas.drawParagraph(paragraph3, Offset(10, 230));
|
|
|
|
2550
|
+
|
|
|
|
2551
|
+ //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
|
|
2552
|
+ var picture =
|
|
|
|
2553
|
+ await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高
|
|
|
|
2554
|
+ var pngImageBytes =
|
|
|
|
2555
|
+ (await picture.toByteData(format: ui.ImageByteFormat.png))!;
|
|
|
|
2556
|
+ // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
|
|
2557
|
+ Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
|
|
2558
|
+ print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
|
|
|
2559
|
+
|
|
|
|
2560
|
+ Uint8List result = await realComporessList(pngBytes); //压缩图片
|
|
|
|
2561
|
+ return result;
|
|
|
|
2562
|
+ }
|
|
|
|
2563
|
+
|
|
|
|
2564
|
+ static Future<Uint8List> canvas2(context, String _thumbnail, DateTime date,
|
|
|
|
2565
|
+ String liteStyle, String dsolt, String ddateHm) async {
|
|
|
|
2566
|
+ var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
|
|
2567
|
+ var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
|
|
2568
|
+ var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
|
|
|
2569
|
+ print(images);
|
|
|
|
2570
|
+ final Paint paint = Paint();
|
|
|
|
2571
|
+ canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
|
|
|
|
2572
|
+
|
|
|
|
2573
|
+ List<String> subType = liteStyle.split('-');
|
|
|
|
2574
|
+ // String subType0 = subType[0]; //几号模版
|
|
|
|
2575
|
+ String subType1 = subType[1]; //模版下面的子样式
|
|
|
|
2576
|
+ String month =
|
|
|
|
2577
|
+ '${Utils.addZeroNumber(date.month)}/${Utils.addZeroNumber(date.day)}';
|
|
|
|
2578
|
+ String week = returnWeek(date, context);
|
|
|
|
2579
|
+ String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm} ' : '';
|
|
|
|
2580
|
+ String section = subType1 == '1' || subType1 == '4'
|
|
|
|
2581
|
+ ? _getDsoltStrShow(dsolt)
|
|
|
|
2582
|
+ : subType1 == '2'
|
|
|
|
2583
|
+ ? _getDsoltStrShow(dsolt, isCan: false)
|
|
|
|
2584
|
+ : '';
|
|
|
|
2585
|
+
|
|
|
|
2586
|
+ String time = week + hour + section;
|
|
|
|
2587
|
+
|
|
|
|
2588
|
+ paint.color = MyColours.color_99000000;
|
|
|
|
2589
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2590
|
+ if (Platform.isIOS) {
|
|
|
|
2591
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2592
|
+ }
|
|
|
|
2593
|
+ // // 绘制图像
|
|
|
|
2594
|
+ canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint);
|
|
|
|
2595
|
+
|
|
|
|
2596
|
+ if (Platform.isIOS) {
|
|
|
|
2597
|
+ final paint1 = Paint()
|
|
|
|
2598
|
+ ..color = MyColours.color_99000000
|
|
|
|
2599
|
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
|
|
|
2600
|
+ ..style = PaintingStyle.fill;
|
|
|
|
2601
|
+ // 绘制一个矩形作为蒙版
|
|
|
|
2602
|
+ canvas.drawRect(Rect.fromLTRB(0, 0, 500, 400), paint1);
|
|
|
|
2603
|
+ }
|
|
|
|
2604
|
+ // 绘制文字
|
|
|
|
2605
|
+ ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2606
|
+ textAlign: TextAlign.center,
|
|
|
|
2607
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2608
|
+ maxLines: 2,
|
|
|
|
2609
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2610
|
+ fontSize: 24));
|
|
|
|
2611
|
+ pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 24));
|
|
|
|
2612
|
+ pb2.addText(
|
|
|
|
2613
|
+ '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
|
|
|
|
2614
|
+
|
|
|
|
2615
|
+ // 设置文本的宽度约束
|
|
|
|
2616
|
+ ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500);
|
|
|
|
2617
|
+ ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
|
|
|
|
2618
|
+ canvas.drawParagraph(paragraph2, Offset(0, 86));
|
|
|
|
2619
|
+
|
|
|
|
2620
|
+ // 绘制文字
|
|
|
|
2621
|
+ ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2622
|
+ textAlign: TextAlign.center,
|
|
|
|
2623
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2624
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2625
|
+ fontSize: 48));
|
|
|
|
2626
|
+ pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 48));
|
|
|
|
2627
|
+ pb3.addText(month);
|
|
|
|
2628
|
+
|
|
|
|
2629
|
+ // 设置文本的宽度约束
|
|
|
|
2630
|
+ ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 500);
|
|
|
|
2631
|
+ ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
|
|
|
|
2632
|
+ canvas.drawParagraph(paragraph3, Offset(0, 190));
|
|
|
|
2633
|
+
|
|
|
|
2634
|
+ // 绘制文字
|
|
|
|
2635
|
+ ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2636
|
+ textAlign: TextAlign.center,
|
|
|
|
2637
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2638
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2639
|
+ fontSize: 24));
|
|
|
|
2640
|
+ pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 24));
|
|
|
|
2641
|
+ pb.addText(time);
|
|
|
|
2642
|
+
|
|
|
|
2643
|
+ // 设置文本的宽度约束
|
|
|
|
2644
|
+ ParagraphConstraints pc = ui.ParagraphConstraints(width: 500);
|
|
|
|
2645
|
+ ui.Paragraph paragraph = pb.build()..layout(pc);
|
|
|
|
2646
|
+ canvas.drawParagraph(paragraph, Offset(0, 270));
|
|
|
|
2647
|
+
|
|
|
|
2648
|
+ //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
|
|
2649
|
+ var picture =
|
|
|
|
2650
|
+ await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高
|
|
|
|
2651
|
+ var pngImageBytes =
|
|
|
|
2652
|
+ (await picture.toByteData(format: ui.ImageByteFormat.png))!;
|
|
|
|
2653
|
+ // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
|
|
2654
|
+ Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
|
|
2655
|
+ print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
|
|
|
2656
|
+
|
|
|
|
2657
|
+ Uint8List result = await realComporessList(pngBytes); //压缩图片
|
|
|
|
2658
|
+ return result;
|
|
|
|
2659
|
+ }
|
|
|
|
2660
|
+
|
|
|
|
2661
|
+ static Future<Uint8List> canvas3(context, String _thumbnail, DateTime date,
|
|
|
|
2662
|
+ String liteStyle, String dsolt, String ddateHm) async {
|
|
|
|
2663
|
+ var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
|
|
2664
|
+ var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
|
|
2665
|
+ var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
|
|
|
2666
|
+ print(images);
|
|
|
|
2667
|
+ final Paint paint = Paint();
|
|
|
|
2668
|
+ canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
|
|
|
|
2669
|
+
|
|
|
|
2670
|
+ List<String> subType = liteStyle.split('-');
|
|
|
|
2671
|
+ // String subType0 = subType[0]; //几号模版
|
|
|
|
2672
|
+ String subType1 = subType[1]; //模版下面的子样式
|
|
|
|
2673
|
+ String month =
|
|
|
|
2674
|
+ '${Utils.addZeroNumber(date.month)}/${Utils.addZeroNumber(date.day)}';
|
|
|
|
2675
|
+ String week = returnWeek(date, context);
|
|
|
|
2676
|
+ String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm}' : '';
|
|
|
|
2677
|
+ String section = subType1 == '1' || subType1 == '4'
|
|
|
|
2678
|
+ ? _getDsoltStrShow(dsolt)
|
|
|
|
2679
|
+ : subType1 == '2'
|
|
|
|
2680
|
+ ? _getDsoltStrShow(dsolt, isCan: false)
|
|
|
|
2681
|
+ : '';
|
|
|
|
2682
|
+
|
|
|
|
2683
|
+ if (hour != '') {
|
|
|
|
2684
|
+ section = section + ' ';
|
|
|
|
2685
|
+ }
|
|
|
|
2686
|
+
|
|
|
|
2687
|
+ String time = section + hour;
|
|
|
|
2688
|
+
|
|
|
|
2689
|
+ paint.color = MyColours.color_99000000;
|
|
|
|
2690
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2691
|
+ if (Platform.isIOS) {
|
|
|
|
2692
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2693
|
+ }
|
|
|
|
2694
|
+ // // 绘制图像
|
|
|
|
2695
|
+ canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint);
|
|
|
|
2696
|
+
|
|
|
|
2697
|
+ if (Platform.isIOS) {
|
|
|
|
2698
|
+ final paint1 = Paint()
|
|
|
|
2699
|
+ ..color = MyColours.color_99000000
|
|
|
|
2700
|
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
|
|
|
2701
|
+ ..style = PaintingStyle.fill;
|
|
|
|
2702
|
+ // 绘制一个矩形作为蒙版
|
|
|
|
2703
|
+ canvas.drawRect(Rect.fromLTRB(0, 0, 500, 400), paint1);
|
|
|
|
2704
|
+ }
|
|
|
|
2705
|
+ // 绘制文字
|
|
|
|
2706
|
+ ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2707
|
+ textAlign: TextAlign.left,
|
|
|
|
2708
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2709
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2710
|
+ maxLines: 2,
|
|
|
|
2711
|
+ fontSize: 24));
|
|
|
|
2712
|
+ pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 24));
|
|
|
|
2713
|
+ pb2.addText(
|
|
|
|
2714
|
+ '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
|
|
|
|
2715
|
+
|
|
|
|
2716
|
+ // 设置文本的宽度约束
|
|
|
|
2717
|
+ ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 500);
|
|
|
|
2718
|
+ ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
|
|
|
|
2719
|
+ canvas.drawParagraph(paragraph2, Offset(35, 50));
|
|
|
|
2720
|
+
|
|
|
|
2721
|
+ // 绘制文字
|
|
|
|
2722
|
+ ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2723
|
+ textAlign: TextAlign.center,
|
|
|
|
2724
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2725
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2726
|
+ fontSize: 48));
|
|
|
|
2727
|
+ pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 48));
|
|
|
|
2728
|
+ pb3.addText(month);
|
|
|
|
2729
|
+
|
|
|
|
2730
|
+ // 设置文本的宽度约束
|
|
|
|
2731
|
+ ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 170);
|
|
|
|
2732
|
+ ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
|
|
|
|
2733
|
+ canvas.drawParagraph(paragraph3, Offset(265, 250));
|
|
|
|
2734
|
+
|
|
|
|
2735
|
+ // 绘制文字
|
|
|
|
2736
|
+ ui.ParagraphBuilder pb4 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2737
|
+ textAlign: TextAlign.center,
|
|
|
|
2738
|
+ height: 1,
|
|
|
|
2739
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2740
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2741
|
+ fontSize: 20));
|
|
|
|
2742
|
+ pb4.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 20));
|
|
|
|
2743
|
+ pb4.addText(week);
|
|
|
|
2744
|
+
|
|
|
|
2745
|
+ // 设置文本的宽度约束
|
|
|
|
2746
|
+ ParagraphConstraints pc4 = ui.ParagraphConstraints(width: 30);
|
|
|
|
2747
|
+ ui.Paragraph paragraph4 = pb4.build()..layout(pc4);
|
|
|
|
2748
|
+ canvas.drawParagraph(paragraph4, Offset(430, 264));
|
|
|
|
2749
|
+
|
|
|
|
2750
|
+ Rect rect = subType1 == '1'
|
|
|
|
2751
|
+ ? Rect.fromLTWH(315, 317, 140, 38)
|
|
|
|
2752
|
+ : Rect.fromLTWH(387, 317, 67, 36);
|
|
|
|
2753
|
+ paint.color = MyColours.color_66FFEFC5;
|
|
|
|
2754
|
+ RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(6));
|
|
|
|
2755
|
+ canvas.drawRRect(rRect, paint);
|
|
|
|
2756
|
+ paint.color = MyColours.color_99000000;
|
|
|
|
2757
|
+
|
|
|
|
2758
|
+ // 绘制文字
|
|
|
|
2759
|
+ ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2760
|
+ textAlign: TextAlign.center,
|
|
|
|
2761
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2762
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2763
|
+ fontSize: 24));
|
|
|
|
2764
|
+ pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 24));
|
|
|
|
2765
|
+ pb.addText(time);
|
|
|
|
2766
|
+
|
|
|
|
2767
|
+ // 设置文本的宽度约束
|
|
|
|
2768
|
+ double width = subType1 == '1' ? 200 : 100;
|
|
|
|
2769
|
+ Offset offset = subType1 == '1' ? Offset(285, 320) : Offset(370, 320);
|
|
|
|
2770
|
+ ParagraphConstraints pc = ui.ParagraphConstraints(width: width);
|
|
|
|
2771
|
+ ui.Paragraph paragraph = pb.build()..layout(pc);
|
|
|
|
2772
|
+ canvas.drawParagraph(paragraph, offset);
|
|
|
|
2773
|
+
|
|
|
|
2774
|
+ //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
|
|
2775
|
+ var picture =
|
|
|
|
2776
|
+ await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高
|
|
|
|
2777
|
+ var pngImageBytes =
|
|
|
|
2778
|
+ (await picture.toByteData(format: ui.ImageByteFormat.png))!;
|
|
|
|
2779
|
+ // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
|
|
2780
|
+ Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
|
|
2781
|
+ print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
|
|
|
2782
|
+
|
|
|
|
2783
|
+ Uint8List result = await realComporessList(pngBytes); //压缩图片
|
|
|
|
2784
|
+ return result;
|
|
|
|
2785
|
+ }
|
|
|
|
2786
|
+
|
|
|
|
2787
|
+ static Future<Uint8List> canvas4(context, String _thumbnail, DateTime date,
|
|
|
|
2788
|
+ String liteStyle, String dsolt, String ddateHm) async {
|
|
|
|
2789
|
+ var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
|
|
2790
|
+ var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
|
|
2791
|
+ var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
|
|
|
2792
|
+ print(images);
|
|
|
|
2793
|
+ final Paint paint = Paint();
|
|
|
|
2794
|
+ canvas.drawImage(images, Offset.zero, paint); //绘制原始图片
|
|
|
|
2795
|
+
|
|
|
|
2796
|
+ List<String> subType = liteStyle.split('-');
|
|
|
|
2797
|
+ // String subType0 = subType[0]; //几号模版
|
|
|
|
2798
|
+ String subType1 = subType[1]; //模版下面的子样式
|
|
|
|
2799
|
+
|
|
|
|
2800
|
+ String month =
|
|
|
|
2801
|
+ '${Utils.addZeroNumber(date.month)}/${Utils.addZeroNumber(date.day)}';
|
|
|
|
2802
|
+ String week = returnWeek(date, context);
|
|
|
|
2803
|
+ String hour = subType1 == '1' || subType1 == '3' ? '${ddateHm}' : '';
|
|
|
|
2804
|
+ String section = subType1 == '1' || subType1 == '4'
|
|
|
|
2805
|
+ ? _getDsoltStrShow(dsolt)
|
|
|
|
2806
|
+ : subType1 == '2'
|
|
|
|
2807
|
+ ? _getDsoltStrShow(dsolt, isCan: false)
|
|
|
|
2808
|
+ : '';
|
|
|
|
2809
|
+
|
|
|
|
2810
|
+ if (section != ''&& hour != '') {
|
|
|
|
2811
|
+ hour = hour + ' ';
|
|
|
|
2812
|
+ }
|
|
|
|
2813
|
+
|
|
|
|
2814
|
+ String time = hour + section;
|
|
|
|
2815
|
+
|
|
|
|
2816
|
+ paint.color = MyColours.color_99000000;
|
|
|
|
2817
|
+ paint.style = PaintingStyle.fill;
|
|
2457
|
if (Platform.isIOS) {
|
2818
|
if (Platform.isIOS) {
|
|
2458
|
- paint = Paint()
|
|
|
|
2459
|
- // ..color = Colors.red
|
|
|
|
2460
|
- // ..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
2819
|
+ paint.style = PaintingStyle.fill;
|
|
|
|
2820
|
+ }
|
|
|
|
2821
|
+ // // 绘制图像
|
|
|
|
2822
|
+ canvas.drawRect(Rect.fromLTWH(0, 300, 500, 100), paint);
|
|
|
|
2823
|
+
|
|
|
|
2824
|
+ if (Platform.isIOS) {
|
|
|
|
2825
|
+ final paint1 = Paint()
|
|
|
|
2826
|
+ ..color = MyColours.color_99000000
|
|
|
|
2827
|
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
|
2461
|
..style = PaintingStyle.fill;
|
2828
|
..style = PaintingStyle.fill;
|
|
|
|
2829
|
+ // 绘制一个矩形作为蒙版
|
|
|
|
2830
|
+ canvas.drawRect(Rect.fromLTWH(0, 300, 500, 100), paint1);
|
|
2462
|
}
|
2831
|
}
|
|
|
|
2832
|
+ // 绘制文字
|
|
|
|
2833
|
+ ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2834
|
+ textAlign: TextAlign.left,
|
|
|
|
2835
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2836
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2837
|
+ maxLines: 1,
|
|
|
|
2838
|
+ fontSize: 20));
|
|
|
|
2839
|
+ pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 20));
|
|
|
|
2840
|
+ pb2.addText(
|
|
|
|
2841
|
+ '${Provider.of<UserModel>(context, listen: false).user!.sellername}');
|
|
|
|
2842
|
+
|
|
|
|
2843
|
+ // 设置文本的宽度约束
|
|
|
|
2844
|
+ ParagraphConstraints pc2 = ui.ParagraphConstraints(width: 320);
|
|
|
|
2845
|
+ ui.Paragraph paragraph2 = pb2.build()..layout(pc2);
|
|
|
|
2846
|
+ canvas.drawParagraph(paragraph2, Offset(20, 337));
|
|
|
|
2847
|
+
|
|
|
|
2848
|
+ // 绘制文字
|
|
|
|
2849
|
+ ui.ParagraphBuilder pb3 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2850
|
+ textAlign: TextAlign.center,
|
|
|
|
2851
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2852
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2853
|
+ fontSize: 20));
|
|
|
|
2854
|
+ pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 20));
|
|
|
|
2855
|
+ pb3.addText(month);
|
|
|
|
2856
|
+
|
|
|
|
2857
|
+ // 设置文本的宽度约束
|
|
|
|
2858
|
+ ParagraphConstraints pc3 = ui.ParagraphConstraints(width: 80);
|
|
|
|
2859
|
+ ui.Paragraph paragraph3 = pb3.build()..layout(pc3);
|
|
|
|
2860
|
+ canvas.drawParagraph(paragraph3, Offset(340, 320));
|
|
|
|
2861
|
+
|
|
|
|
2862
|
+ // 绘制文字
|
|
|
|
2863
|
+ ui.ParagraphBuilder pb4 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2864
|
+ textAlign: TextAlign.center,
|
|
|
|
2865
|
+ // height: 1,
|
|
|
|
2866
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2867
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2868
|
+ fontSize: 20));
|
|
|
|
2869
|
+ pb4.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 20));
|
|
|
|
2870
|
+ pb4.addText(week);
|
|
|
|
2871
|
+
|
|
|
|
2872
|
+ // 设置文本的宽度约束
|
|
|
|
2873
|
+ ParagraphConstraints pc4 = ui.ParagraphConstraints(width: 50);
|
|
|
|
2874
|
+ ui.Paragraph paragraph4 = pb4.build()..layout(pc4);
|
|
|
|
2875
|
+ canvas.drawParagraph(paragraph4, Offset(420, 320));
|
|
|
|
2876
|
+
|
|
|
|
2877
|
+ Rect rect = Rect.fromLTWH(350, 351, 118, 30);
|
|
|
|
2878
|
+ paint.color = MyColours.color_66FFEFC5;
|
|
|
|
2879
|
+ RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(6));
|
|
|
|
2880
|
+ canvas.drawRRect(rRect, paint);
|
|
|
|
2881
|
+ paint.color = MyColours.color_99000000;
|
|
|
|
2882
|
+
|
|
|
|
2883
|
+ // 绘制文字
|
|
|
|
2884
|
+ ui.ParagraphBuilder pb = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
|
|
2885
|
+ textAlign: TextAlign.center,
|
|
|
|
2886
|
+ fontWeight: FontWeight.bold,
|
|
|
|
2887
|
+ fontStyle: FontStyle.normal,
|
|
|
|
2888
|
+ fontSize: 20));
|
|
|
|
2889
|
+ pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 20));
|
|
|
|
2890
|
+ pb.addText(time);
|
|
2463
|
|
2891
|
|
|
2464
|
- // canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint);
|
2892
|
+ // 设置文本的宽度约束
|
|
|
|
2893
|
+
|
|
|
|
2894
|
+ Offset offset = subType1 == '1' ? Offset(348, 353) : Offset(348, 353);
|
|
|
|
2895
|
+ ParagraphConstraints pc = ui.ParagraphConstraints(width: 118);
|
|
|
|
2896
|
+ ui.Paragraph paragraph = pb.build()..layout(pc);
|
|
|
|
2897
|
+ canvas.drawParagraph(paragraph, offset);
|
|
|
|
2898
|
+
|
|
|
|
2899
|
+ //下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
|
|
2900
|
+ var picture =
|
|
|
|
2901
|
+ await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高
|
|
|
|
2902
|
+ var pngImageBytes =
|
|
|
|
2903
|
+ (await picture.toByteData(format: ui.ImageByteFormat.png))!;
|
|
|
|
2904
|
+ // var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
|
|
2905
|
+ Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
|
|
2906
|
+ print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
|
2465
|
|
2907
|
|
|
2466
|
- // canvas.drawImage(images, Offset(0, 0), paint);
|
2908
|
+ Uint8List result = await realComporessList(pngBytes); //压缩图片
|
|
|
|
2909
|
+ return result;
|
|
|
|
2910
|
+ }
|
|
2467
|
|
2911
|
|
|
|
|
2912
|
+ static Future<Uint8List> canvasold(
|
|
|
|
2913
|
+ context, String _thumbnail, String month, String week) async {
|
|
|
|
2914
|
+ var pictureRecorder = new ui.PictureRecorder(); // 图片记录仪
|
|
|
|
2915
|
+ var canvas = new Canvas(pictureRecorder); //canvas接受一个图片记录仪
|
|
|
|
2916
|
+ var images = await loadImage(_thumbnail, true); // 使用方法获取Unit8List格式的图片
|
|
|
|
2917
|
+ print(images);
|
|
|
|
2918
|
+ Paint paint = Paint()
|
|
|
|
2919
|
+ ..color = Color.fromRGBO(81, 81, 81, 0.4)
|
|
|
|
2920
|
+ ..style = PaintingStyle.fill;
|
|
|
|
2921
|
+ if (Platform.isIOS) {
|
|
|
|
2922
|
+ paint = Paint()..style = PaintingStyle.fill;
|
|
|
|
2923
|
+ }
|
|
2468
|
// 定义源矩形,通常是图像的全部
|
2924
|
// 定义源矩形,通常是图像的全部
|
|
2469
|
final Rect source = Rect.fromLTWH(
|
2925
|
final Rect source = Rect.fromLTWH(
|
|
2470
|
0.0, 0.0, images.width.toDouble(), images.height.toDouble());
|
2926
|
0.0, 0.0, images.width.toDouble(), images.height.toDouble());
|
|
@@ -2472,31 +2928,19 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2472,31 +2928,19 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2472
|
final Rect destination = Rect.fromLTWH(0.0, 0.0, 500, 400);
|
2928
|
final Rect destination = Rect.fromLTWH(0.0, 0.0, 500, 400);
|
|
2473
|
// 绘制图像
|
2929
|
// 绘制图像
|
|
2474
|
canvas.drawImageRect(images, source, destination, paint);
|
2930
|
canvas.drawImageRect(images, source, destination, paint);
|
|
2475
|
-
|
|
|
|
2476
|
if (Platform.isIOS) {
|
2931
|
if (Platform.isIOS) {
|
|
2477
|
final paint1 = Paint()
|
2932
|
final paint1 = Paint()
|
|
2478
|
..color = Colors.black.withOpacity(0.6)
|
2933
|
..color = Colors.black.withOpacity(0.6)
|
|
2479
|
..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
2934
|
..maskFilter = MaskFilter.blur(BlurStyle.normal, 5.0)
|
|
2480
|
..style = PaintingStyle.fill;
|
2935
|
..style = PaintingStyle.fill;
|
|
2481
|
-
|
|
|
|
2482
|
// 绘制一个矩形作为蒙版
|
2936
|
// 绘制一个矩形作为蒙版
|
|
2483
|
canvas.drawRect(Rect.fromLTRB(0, 0, 500, 400), paint1);
|
2937
|
canvas.drawRect(Rect.fromLTRB(0, 0, 500, 400), paint1);
|
|
2484
|
}
|
2938
|
}
|
|
2485
|
-
|
|
|
|
2486
|
- // 在画布上绘制图片,使用BoxFit来适配画布大小
|
|
|
|
2487
|
- // canvas.drawImageRect(
|
|
|
|
2488
|
- // images,
|
|
|
|
2489
|
- // Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
|
|
|
|
2490
|
- // Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
|
|
|
|
2491
|
- // paint);
|
|
|
|
2492
|
-
|
|
|
|
2493
|
// 绘制文字
|
2939
|
// 绘制文字
|
|
2494
|
ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
2940
|
ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(
|
|
2495
|
textAlign: TextAlign.center,
|
2941
|
textAlign: TextAlign.center,
|
|
2496
|
fontWeight: FontWeight.normal,
|
2942
|
fontWeight: FontWeight.normal,
|
|
2497
|
fontStyle: FontStyle.normal,
|
2943
|
fontStyle: FontStyle.normal,
|
|
2498
|
-
|
|
|
|
2499
|
- // :MyColours.color_000000,
|
|
|
|
2500
|
fontSize: 26));
|
2944
|
fontSize: 26));
|
|
2501
|
pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 26));
|
2945
|
pb2.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 26));
|
|
2502
|
pb2.addText(
|
2946
|
pb2.addText(
|
|
@@ -2512,8 +2956,6 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2512,8 +2956,6 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2512
|
textAlign: TextAlign.center,
|
2956
|
textAlign: TextAlign.center,
|
|
2513
|
fontWeight: FontWeight.bold,
|
2957
|
fontWeight: FontWeight.bold,
|
|
2514
|
fontStyle: FontStyle.normal,
|
2958
|
fontStyle: FontStyle.normal,
|
|
2515
|
-
|
|
|
|
2516
|
- // :MyColours.color_000000,
|
|
|
|
2517
|
fontSize: 48));
|
2959
|
fontSize: 48));
|
|
2518
|
pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 48));
|
2960
|
pb.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 48));
|
|
2519
|
pb.addText(month);
|
2961
|
pb.addText(month);
|
|
@@ -2528,8 +2970,6 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2528,8 +2970,6 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2528
|
textAlign: TextAlign.center,
|
2970
|
textAlign: TextAlign.center,
|
|
2529
|
fontWeight: FontWeight.bold,
|
2971
|
fontWeight: FontWeight.bold,
|
|
2530
|
fontStyle: FontStyle.normal,
|
2972
|
fontStyle: FontStyle.normal,
|
|
2531
|
-
|
|
|
|
2532
|
- // :MyColours.color_000000,
|
|
|
|
2533
|
fontSize: 42));
|
2973
|
fontSize: 42));
|
|
2534
|
pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 42));
|
2974
|
pb3.pushStyle(ui.TextStyle(color: MyColours.color_FFEFC5, fontSize: 42));
|
|
2535
|
pb3.addText(week);
|
2975
|
pb3.addText(week);
|
|
@@ -2540,19 +2980,16 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2540,19 +2980,16 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2540
|
canvas.drawParagraph(paragraph3, Offset(10, 230));
|
2980
|
canvas.drawParagraph(paragraph3, Offset(10, 230));
|
|
2541
|
|
2981
|
|
|
2542
|
//下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
2982
|
//下面的代码是生成图片的关键代码,以上绘制文字和圆圈的代码可以忽略不计
|
|
2543
|
- var picture =
|
|
|
|
2544
|
- await pictureRecorder.endRecording().toImage(500, 400); //设置生成图片的宽和高
|
2983
|
+ var picture = await pictureRecorder
|
|
|
|
2984
|
+ .endRecording()
|
|
|
|
2985
|
+ .toImage(w(210).toInt(), w(168).toInt()); //设置生成图片的宽和高
|
|
2545
|
var pngImageBytes =
|
2986
|
var pngImageBytes =
|
|
2546
|
(await picture.toByteData(format: ui.ImageByteFormat.png))!;
|
2987
|
(await picture.toByteData(format: ui.ImageByteFormat.png))!;
|
|
2547
|
// var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
2988
|
// var imgBytes = Uint8List.view(pngImageBytes.buffer); //这一行和下面这一行都是生成Uint8List格式的图片(原理还不知道)
|
|
2548
|
Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
2989
|
Uint8List pngBytes = pngImageBytes.buffer.asUint8List();
|
|
2549
|
print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
2990
|
print(pngBytes); //pngBytes可以放在Image.memory()中预览
|
|
2550
|
- // setState(() {
|
|
|
|
2551
|
- // imageMemory = pngBytes;
|
|
|
|
2552
|
- // Uint8List result = await resizeImage(pngBytes); //重置图片尺寸
|
|
|
|
2553
|
|
2991
|
|
|
2554
|
Uint8List result = await realComporessList(pngBytes); //压缩图片
|
2992
|
Uint8List result = await realComporessList(pngBytes); //压缩图片
|
|
2555
|
- // Uint8List result = await testFromFileComporessList(context, pngBytes,needResize: true);
|
|
|
|
2556
|
return result;
|
2993
|
return result;
|
|
2557
|
}
|
2994
|
}
|
|
2558
|
|
2995
|
|
|
@@ -2605,13 +3042,13 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2605,13 +3042,13 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2605
|
late Uint8List _thumbnailUint8List;
|
3042
|
late Uint8List _thumbnailUint8List;
|
|
2606
|
print(size(_thumbnail.length));
|
3043
|
print(size(_thumbnail.length));
|
|
2607
|
if (liteStyle != '0') {
|
3044
|
if (liteStyle != '0') {
|
|
2608
|
- _thumbnailUint8List = await canvas(
|
|
|
|
2609
|
- context,
|
|
|
|
2610
|
- sellerImage == null || sellerImage == ''
|
|
|
|
2611
|
- ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
2612
|
- : sellerImage,
|
|
|
|
2613
|
- month,
|
|
|
|
2614
|
- week);
|
3045
|
+ // _thumbnailUint8List = await canvas(
|
|
|
|
3046
|
+ // context,
|
|
|
|
3047
|
+ // sellerImage == null || sellerImage == ''
|
|
|
|
3048
|
+ // ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
3049
|
+ // : sellerImage,
|
|
|
|
3050
|
+ // month,
|
|
|
|
3051
|
+ // week);
|
|
2615
|
}
|
3052
|
}
|
|
2616
|
String _title =
|
3053
|
String _title =
|
|
2617
|
"您预订的${Provider.of<UserModel>(context, listen: false).user!.sellername},已经安排,点击查看详情";
|
3054
|
"您预订的${Provider.of<UserModel>(context, listen: false).user!.sellername},已经安排,点击查看详情";
|
|
@@ -2643,23 +3080,26 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2643,23 +3080,26 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2643
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
3080
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
2644
|
|
3081
|
|
|
2645
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
3082
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
2646
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
2647
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
|
|
|
2648
|
- }
|
3083
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
3084
|
+ result = resultnew == null
|
|
|
|
3085
|
+ ? null
|
|
|
|
3086
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
|
|
3087
|
+ }
|
|
2649
|
}
|
3088
|
}
|
|
2650
|
|
3089
|
|
|
2651
|
var model = new WeChatShareMiniProgramModel(
|
3090
|
var model = new WeChatShareMiniProgramModel(
|
|
2652
|
- webPageUrl: _webPageUrl,
|
|
|
|
2653
|
- userName: _userName,
|
|
|
|
2654
|
- title: _title,
|
|
|
|
2655
|
- path: _path,
|
|
|
|
2656
|
- description: _description,
|
|
|
|
2657
|
- miniProgramType: Constant.wxMiniProgramType, //
|
|
|
|
2658
|
- // miniProgramType: WXMiniProgramType.RELEASE, //正式版
|
|
|
|
2659
|
- // miniProgramType: //开发版
|
|
|
|
2660
|
- // thumbnail: WeChatImage.binary(source)
|
|
|
|
2661
|
- // thumbnail: WeChatImage.network(_thumbnail)
|
|
|
|
2662
|
- thumbData: liteStyle == '0' ? result : _thumbnailUint8List);
|
3091
|
+ webPageUrl: _webPageUrl,
|
|
|
|
3092
|
+ userName: _userName,
|
|
|
|
3093
|
+ title: _title,
|
|
|
|
3094
|
+ path: _path,
|
|
|
|
3095
|
+ description: _description,
|
|
|
|
3096
|
+ miniProgramType: Constant.wxMiniProgramType, //
|
|
|
|
3097
|
+ // miniProgramType: WXMiniProgramType.RELEASE, //正式版
|
|
|
|
3098
|
+ // miniProgramType: //开发版
|
|
|
|
3099
|
+ // thumbnail: WeChatImage.binary(source)
|
|
|
|
3100
|
+ // thumbnail: WeChatImage.network(_thumbnail)
|
|
|
|
3101
|
+ // thumbData: liteStyle == '0' ? result : _thumbnailUint8List
|
|
|
|
3102
|
+ );
|
|
2663
|
|
3103
|
|
|
2664
|
isSuccess = await fluwx.share(model);
|
3104
|
isSuccess = await fluwx.share(model);
|
|
2665
|
} else {
|
3105
|
} else {
|
|
@@ -2702,13 +3142,32 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2702,13 +3142,32 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2702
|
return isSuccess;
|
3142
|
return isSuccess;
|
|
2703
|
}
|
3143
|
}
|
|
2704
|
|
3144
|
|
|
|
|
3145
|
+ static _getDsoltStrShow(String ddateSolt, {bool isCan = true}) {
|
|
|
|
3146
|
+ String dsoltStr = '';
|
|
|
|
3147
|
+ if (!isCan) {
|
|
|
|
3148
|
+ dsoltStr = ddateSolt == '1'
|
|
|
|
3149
|
+ ? '早上'
|
|
|
|
3150
|
+ : ddateSolt == '2'
|
|
|
|
3151
|
+ ? '中午'
|
|
|
|
3152
|
+ : '晚上';
|
|
|
|
3153
|
+ } else {
|
|
|
|
3154
|
+ dsoltStr = ddateSolt == '1'
|
|
|
|
3155
|
+ ? '早餐'
|
|
|
|
3156
|
+ : ddateSolt == '2'
|
|
|
|
3157
|
+ ? '午餐'
|
|
|
|
3158
|
+ : '晚餐';
|
|
|
|
3159
|
+ }
|
|
|
|
3160
|
+ return dsoltStr;
|
|
|
|
3161
|
+ }
|
|
|
|
3162
|
+
|
|
2705
|
//分享邀请函
|
3163
|
//分享邀请函
|
|
2706
|
static goShareInvicationToWeChat(
|
3164
|
static goShareInvicationToWeChat(
|
|
2707
|
BuildContext context,
|
3165
|
BuildContext context,
|
|
2708
|
String rid,
|
3166
|
String rid,
|
|
2709
|
String? uid,
|
3167
|
String? uid,
|
|
2710
|
- String month,
|
|
|
|
2711
|
- String week,
|
3168
|
+ String ddateHm,
|
|
|
|
3169
|
+ DateTime dateTime,
|
|
|
|
3170
|
+ String ddateSolt,
|
|
2712
|
String? liteStyle,
|
3171
|
String? liteStyle,
|
|
2713
|
String? liteStyleTitle,
|
3172
|
String? liteStyleTitle,
|
|
2714
|
{bool isWechat = true,
|
3173
|
{bool isWechat = true,
|
|
@@ -2725,14 +3184,55 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2725,14 +3184,55 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2725
|
: sellerImage;
|
3184
|
: sellerImage;
|
|
2726
|
late Uint8List _thumbnailUint8List;
|
3185
|
late Uint8List _thumbnailUint8List;
|
|
2727
|
print(size(_thumbnail.length));
|
3186
|
print(size(_thumbnail.length));
|
|
|
|
3187
|
+
|
|
|
|
3188
|
+ String dsoltStr = '${ddateHm == null || ddateHm == '' ? '' : ddateHm}';
|
|
|
|
3189
|
+ // dsoltStr = _getDsoltStrShow(liteStyle!, ddateSolt);
|
|
2728
|
if (liteStyle != '0') {
|
3190
|
if (liteStyle != '0') {
|
|
2729
|
- _thumbnailUint8List = await canvas(
|
|
|
|
2730
|
- context,
|
|
|
|
2731
|
- sellerImage == null || sellerImage == ''
|
|
|
|
2732
|
- ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
2733
|
- : sellerImage,
|
|
|
|
2734
|
- month,
|
|
|
|
2735
|
- week);
|
3191
|
+ //画图
|
|
|
|
3192
|
+ // 4种情况的图分别画出来
|
|
|
|
3193
|
+ List<String> subType = liteStyle!.split('-');
|
|
|
|
3194
|
+ String subType0 = subType[0]; //几号模版
|
|
|
|
3195
|
+ if (subType0 == '1') {
|
|
|
|
3196
|
+ _thumbnailUint8List = await canvas(
|
|
|
|
3197
|
+ context,
|
|
|
|
3198
|
+ sellerImage == null || sellerImage == ''
|
|
|
|
3199
|
+ ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
3200
|
+ : sellerImage,
|
|
|
|
3201
|
+ dateTime,
|
|
|
|
3202
|
+ liteStyle,
|
|
|
|
3203
|
+ ddateSolt,
|
|
|
|
3204
|
+ ddateHm);
|
|
|
|
3205
|
+ } else if (subType0 == '2') {
|
|
|
|
3206
|
+ _thumbnailUint8List = await canvas2(
|
|
|
|
3207
|
+ context,
|
|
|
|
3208
|
+ sellerImage == null || sellerImage == ''
|
|
|
|
3209
|
+ ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
3210
|
+ : sellerImage,
|
|
|
|
3211
|
+ dateTime,
|
|
|
|
3212
|
+ liteStyle,
|
|
|
|
3213
|
+ ddateSolt,
|
|
|
|
3214
|
+ ddateHm);
|
|
|
|
3215
|
+ } else if (subType0 == '3') {
|
|
|
|
3216
|
+ _thumbnailUint8List = await canvas3(
|
|
|
|
3217
|
+ context,
|
|
|
|
3218
|
+ sellerImage == null || sellerImage == ''
|
|
|
|
3219
|
+ ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
3220
|
+ : sellerImage,
|
|
|
|
3221
|
+ dateTime,
|
|
|
|
3222
|
+ liteStyle,
|
|
|
|
3223
|
+ ddateSolt,
|
|
|
|
3224
|
+ ddateHm);
|
|
|
|
3225
|
+ } else {
|
|
|
|
3226
|
+ _thumbnailUint8List = await canvas4(
|
|
|
|
3227
|
+ context,
|
|
|
|
3228
|
+ sellerImage == null || sellerImage == ''
|
|
|
|
3229
|
+ ? 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'
|
|
|
|
3230
|
+ : sellerImage,
|
|
|
|
3231
|
+ dateTime,
|
|
|
|
3232
|
+ liteStyle,
|
|
|
|
3233
|
+ ddateSolt,
|
|
|
|
3234
|
+ ddateHm);
|
|
|
|
3235
|
+ }
|
|
2736
|
}
|
3236
|
}
|
|
2737
|
String _title = liteStyleTitle ??
|
3237
|
String _title = liteStyleTitle ??
|
|
2738
|
"您预订的${Provider.of<UserModel>(context, listen: false).user!.sellername},已经安排,点击查看详情";
|
3238
|
"您预订的${Provider.of<UserModel>(context, listen: false).user!.sellername},已经安排,点击查看详情";
|
|
@@ -2759,14 +3259,16 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2759,14 +3259,16 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2759
|
"pages/customer/detail_owner_invitation_new?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid&paymentId=$depositId";
|
3259
|
"pages/customer/detail_owner_invitation_new?id=$rid&hasInvitation=1&hasSellerShare=1&uid=$uid&paymentId=$depositId";
|
|
2760
|
}
|
3260
|
}
|
|
2761
|
Fluwx fluwx = Fluwx();
|
3261
|
Fluwx fluwx = Fluwx();
|
|
2762
|
- Uint8List? result;
|
3262
|
+ Uint8List? result;
|
|
2763
|
if (liteStyle == '0') {
|
3263
|
if (liteStyle == '0') {
|
|
2764
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
3264
|
Uint8List? pngByte = await WxSdk.fetchImageAsUint8List(_thumbnail);
|
|
2765
|
|
3265
|
|
|
2766
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
3266
|
if (pngByte != null && await isImageLargerThan64KB(pngByte)) {
|
|
2767
|
- Uint8List? resultnew= await realComporessList(pngByte); //压缩图片
|
|
|
|
2768
|
- result=resultnew ==null ? null : await compressImage(resultnew,mb:64/1024);
|
|
|
|
2769
|
- }
|
3267
|
+ Uint8List? resultnew = await realComporessList(pngByte); //压缩图片
|
|
|
|
3268
|
+ result = resultnew == null
|
|
|
|
3269
|
+ ? null
|
|
|
|
3270
|
+ : await compressImage(resultnew, mb: 64 / 1024);
|
|
|
|
3271
|
+ }
|
|
2770
|
}
|
3272
|
}
|
|
2771
|
// print(_thumbnailUint8List.length/1024);
|
3273
|
// print(_thumbnailUint8List.length/1024);
|
|
2772
|
var model = new WeChatShareMiniProgramModel(
|
3274
|
var model = new WeChatShareMiniProgramModel(
|
|
@@ -2780,9 +3282,7 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
@@ -2780,9 +3282,7 @@ static Future<bool> isImageLargerThan64KB(Uint8List? imageBytes) async { |
|
2780
|
// miniProgramType: //开发版
|
3282
|
// miniProgramType: //开发版
|
|
2781
|
// thumbnail: WeChatImage.binary(source)
|
3283
|
// thumbnail: WeChatImage.binary(source)
|
|
2782
|
// thumbnail: WeChatImage.network(_thumbnail)
|
3284
|
// thumbnail: WeChatImage.network(_thumbnail)
|
|
2783
|
- thumbData: liteStyle == '0'
|
|
|
|
2784
|
- ? result
|
|
|
|
2785
|
- : _thumbnailUint8List);
|
3285
|
+ thumbData: liteStyle == '0' ? result : _thumbnailUint8List);
|
|
2786
|
|
3286
|
|
|
2787
|
// thumbData: );
|
3287
|
// thumbData: );
|
|
2788
|
|
3288
|
|