From a916f145674ecd5cf8cf45bca206c924c3720deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E6=96=87=E8=BD=A9?= <12812285557@qq.com> Date: Tue, 14 Jun 2022 09:43:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=96=B0=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E7=BA=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/libraries/Flutter_Plugins.xml | 1 + .idea/runConfigurations.xml | 10 + .idea/workspace.xml | 22 +- android/build.gradle | 1 + .../com/dj/printer/dj_printer/AsPrint.java | 106 ++++- .../printer/dj_printer/DjPrinterPlugin.java | 18 +- dj_printer.iml | 1 + example/android/build.gradle | 2 + example/lib/main.dart | 168 +++++++- example/pubspec.lock | 91 +++-- example/pubspec.yaml | 2 + lib/dj_printer.dart | 372 ++++++++++++++++++ pubspec.lock | 77 +++- pubspec.yaml | 5 + 14 files changed, 803 insertions(+), 73 deletions(-) create mode 100644 .idea/runConfigurations.xml diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index 53449da..8b834e2 100644 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -2,6 +2,7 @@ + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1cfc7b8..32a31f0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,15 +1,23 @@ + + - + - - + + + + + + + - + + + + @@ -95,6 +106,7 @@ + diff --git a/android/build.gradle b/android/build.gradle index 9c178d8..f409ca4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -24,6 +24,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 30 + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java b/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java index 1595b14..e53a18c 100644 --- a/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java +++ b/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java @@ -1,5 +1,7 @@ package com.dj.printer.dj_printer; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Typeface; import com.sewoo.jpos.command.CPCLConst; @@ -7,6 +9,8 @@ import com.sewoo.jpos.printer.CPCLPrinter; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.util.Arrays; + public class AsPrint { @@ -20,23 +24,98 @@ public class AsPrint { cpclPrinter.setMeasure(CPCLConst.LK_CPCL_MILLI); } - public void printAsCode(String code, String channel, String country, String countStr, int offset, boolean hasPlan) throws IOException { - printTest(); -// if (hasPlan) { -// PrintPlan(code, channel, country, countStr, offset); -// } else { -// PrintNoPlan(code, countStr, offset); -// } + public void printAsCode(String code, String channel, String country, String countStr, + int offset, boolean hasPlan, byte[] bytesCode, byte[] bytesChannel, + byte[] bytesCountry ,byte[] bytesBarCode,byte[] bytesNum ,byte[] bytesSum) throws IOException { + + + Bitmap imgCode = BitmapFactory.decodeByteArray(bytesCode, 0, bytesCode.length); + + Bitmap imgChannel = BitmapFactory.decodeByteArray(bytesChannel, 0, bytesChannel.length); + + Bitmap imgCountry = BitmapFactory.decodeByteArray(bytesCountry, 0, bytesCountry.length); + + Bitmap imgBarCode = BitmapFactory.decodeByteArray(bytesBarCode, 0, bytesBarCode.length); + + Bitmap imgNum = BitmapFactory.decodeByteArray(bytesNum, 0, bytesNum.length); + + Bitmap imgSum = BitmapFactory.decodeByteArray(bytesSum, 0, bytesSum.length); + + + + if (hasPlan) { + printNewPlan(code, channel, country, countStr, offset, imgCode, imgChannel, imgCountry,imgBarCode,imgNum,imgSum); + } else { + printNewNoPlan(code, channel, country, countStr, offset, imgCode, imgCountry,imgBarCode,imgNum,imgSum); + } } - private void printTest() throws UnsupportedEncodingException { - cpclPrinter.setForm(0, 203, 203, 500, 575, 0, 1); + private void printNewPlan(String code, String channel, String country, String countStr, int offset, + Bitmap imgCode, Bitmap imgChannel, Bitmap imgCountry, + Bitmap imgBarCode,Bitmap imgNum,Bitmap imgSum) throws IOException { + + cpclPrinter.setForm(3, 203, 203, 800, 575, 0, 1); + cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL); - cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER); - cpclPrinter.printBox(5,5,500,300,3); - cpclPrinter.printLine(5,50,500,50,3); - cpclPrinter.printLine(430,300,480,250,3); + cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT); + + cpclPrinter.printBox(0, 7, 570, 800, 3); + + cpclPrinter.printLine(265, 7, 265, 800, 3); + + cpclPrinter.printLine(424, 7, 424, 800, 3); + + cpclPrinter.printLine(0, 526, 424, 526, 3); + + cpclPrinter.printLine(70, 590, 200, 730, 3); + + cpclPrinter.printBitmap(imgCode, 460, 50); + + cpclPrinter.printBitmap(imgChannel, 295, 60); + + cpclPrinter.printBitmap(imgCountry, 320, country.length()>3?570:580); + + cpclPrinter.printBitmap(imgBarCode, 40, 80); + + cpclPrinter.printBitmap(imgNum, 150, 600); + + cpclPrinter.printBitmap(imgSum, 70, 690); + + cpclPrinter.printForm(); + } + + + private void printNewNoPlan(String code, String channel, String country, String countStr, int offset, + Bitmap imgCode, Bitmap imgCountry, + Bitmap imgBarCode,Bitmap imgNum,Bitmap imgSum) throws IOException { + + cpclPrinter.setForm(3, 203, 203, 800, 575, 0, 1); + + cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL); + + cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT); + + cpclPrinter.printBox(0, 10, 570, 795, 3); + + cpclPrinter.printLine(265, 10, 265, 795, 3); + + cpclPrinter.printLine(424, 10, 424, 795, 3); + + cpclPrinter.printLine(0, 526, 265, 526, 3); + + cpclPrinter.printLine(70, 590, 200, 730, 3); + + cpclPrinter.printBitmap(imgCode, 460, 50); + + cpclPrinter.printBitmap(imgCountry, 320,270); + + cpclPrinter.printBitmap(imgBarCode, 40, 80); + + cpclPrinter.printBitmap(imgNum, 150, 600); + + cpclPrinter.printBitmap(imgSum, 70, 690); + cpclPrinter.printForm(); } @@ -78,3 +157,4 @@ public class AsPrint { return cpclPrinter.status(); } } + diff --git a/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java b/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java index d7807a4..ff8702e 100644 --- a/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java +++ b/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java @@ -90,7 +90,23 @@ public class DjPrinterPlugin implements FlutterPlugin, MethodCallHandler { String countStr = call.argument("countStr"); int offset = call.argument("offset"); boolean hasPlan = call.argument("hasPlan"); - asPrint.printAsCode(code, channel, country, countStr, offset, hasPlan); + + byte[] byteCode = call.argument("byteCode"); + + byte[] bytesChannel = call.argument("bytesChannel"); + + byte[] bytesCountry = call.argument("bytesCountry"); + + byte[] bytesBarCode =call.argument("bytesBarCode"); + + byte[] bytesSum = call.argument("bytesSum"); + + byte[] bytesNum =call.argument("bytesNum"); + + + asPrint.printAsCode(code, channel, country, countStr, offset, hasPlan,byteCode,bytesChannel,bytesCountry,bytesBarCode,bytesNum,bytesSum); + //asPrint.printAsCode(); + } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { diff --git a/dj_printer.iml b/dj_printer.iml index 778b2e2..3de6ac7 100644 --- a/dj_printer.iml +++ b/dj_printer.iml @@ -12,6 +12,7 @@ + diff --git a/example/android/build.gradle b/example/android/build.gradle index 622ddc5..09fbd64 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,4 +1,5 @@ buildscript { + ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() @@ -6,6 +7,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 420a70e..cd6cdcf 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; +import 'package:barcode_widget/barcode_widget.dart'; import 'package:dj_printer/dj_printer.dart'; import 'package:dj_printer/src/device_model.dart'; import 'package:flutter/material.dart'; @@ -73,6 +74,7 @@ class _MyAppState extends State { TextButton( onPressed: () { devices.clear(); + setState(() {}); DjPrinter().startSearch; }, child: const Text('扫描设备')), @@ -92,13 +94,13 @@ class _MyAppState extends State { ), TextButton( onPressed: () { - DjPrinter().printAScode( + DjPrinter().printAScodeByImg( code: 'ASSZ2022012500010002', - channel: 'cosco定提-月达-卡派', - country: '美国', + channel: '加拿大温哥华海派快线-卡派/UPS派送', + country: '加拿大', countStr: '10/20', offset: 0, - hasPlan: false); + hasPlan: false, sum: '20', num: '5'); }, child: const Text('打印')), @@ -109,11 +111,167 @@ class _MyAppState extends State { onPressed: () { DjPrinter().disposeConnect(); }, - child: const Text('取消链接')) + child: const Text('取消链接')), + + _getCard('ASSZ2022012500010002', '加拿大温哥华海派快线-卡派/UPS派送', '加拿大', + '10/20', 0, true) ], ), ), ), ); } + + _getCard(String code, String channel, String country, String countStr, + int offset, bool hasPlan) { + return Container( + margin: EdgeInsets.all(5), + width: 90, + height: 200, + color: Colors.red, + // decoration: BoxDecoration( + // border: Border.all(color: Colors.black,width: 2) + // ), + + child: RotatedBox( + quarterTurns: 1, + child: BarcodeWidget( + barcode: Barcode.code128(), + data: code, + style: TextStyle( + fontSize: 10 + ), + ), + ) + + // + // Row( + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Container( + // width: 197 / 3.7, + // height: 950 / 3.7, + // decoration: BoxDecoration( + // color: Colors.white, + // border: Border( + // right: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // code, + // style: TextStyle( + // color: Colors.black, + // fontSize: 20, + // fontWeight: FontWeight.bold), + // ), + // ), + // ), + // Container( + // width: 215 / 3.7, + // height: 950 / 3.7, + // decoration: BoxDecoration( + // border: Border( + // right: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + // alignment: Alignment.center, + // child: Column( + // children: [ + // Container( + // width: 215 / 3.7, + // height: 950 / 3.7 / 3, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // country, + // style: TextStyle( + // color: Colors.black, + // fontSize: 17, + // fontWeight: FontWeight.bold), + // ), + // ), + // ), + // Container( + // width: 215 / 3.7, + // height: 950 / 3.7 / 3 * 2 - 4, + // padding: EdgeInsets.symmetric(vertical: 10), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // channel, + // style: TextStyle( + // color: Colors.black, + // fontSize: 15, + // ), + // ), + // ), + // ) + // ], + // )), + // Container( + // width: 358 / 3.7 -20, + // height: 950 / 3.7, + // alignment: Alignment.center, + // child: Column( + // children: [ + // Container( + // width: 358 / 3.7 -20, + // height: 950 / 3.7 / 3, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // countStr, + // style: TextStyle( + // color: Colors.black, + // fontSize: 17, + // fontWeight: FontWeight.bold), + // ), + // ), + // ), + // Container( + // width: 358 / 3.7 -30, + // height: 950 / 3.7 / 3 * 2 - 1.5, + // padding: EdgeInsets.only(left: 15,top: 15,bottom: 15,right: 10) , + // child: RotatedBox( + // quarterTurns: 3, + // child: BarcodeWidget( + // + // barcode: Barcode.code128(), + // data: code, + // style: TextStyle( + // fontSize: 10 + // ), + // ), + // ), + // ) + // ], + // )), + // ], + // ), + ); + } } diff --git a/example/pubspec.lock b/example/pubspec.lock index c093bf6..eb956d7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,56 +5,70 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.8.2" + barcode: + dependency: transitive + description: + name: barcode + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + barcode_widget: + dependency: "direct main" + description: + name: barcode_widget + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" bot_toast: dependency: "direct main" description: name: bot_toast - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "4.0.2" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.5" dj_printer: @@ -68,7 +82,7 @@ packages: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" flutter: @@ -76,11 +90,18 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_image_compress: + dependency: transitive + description: + name: flutter_image_compress + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.4" flutter_test: @@ -92,79 +113,86 @@ packages: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.12.11" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.1.4" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.7.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.8.1" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "9.2.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "9.0.2+1" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "9.0.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "3.7.0" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.2" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" sky_engine: dependency: transitive description: flutter @@ -174,51 +202,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.4.9" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.2" + widget_to_image: + dependency: "direct main" + description: + name: widget_to_image + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" sdks: dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.8.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 21ec4ed..2f3f1d9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -30,6 +30,8 @@ dependencies: cupertino_icons: ^1.0.2 permission_handler: ^9.2.0 bot_toast: ^4.0.1 + widget_to_image: ^2.0.0 + barcode_widget: ^2.0.2 dev_dependencies: flutter_test: diff --git a/lib/dj_printer.dart b/lib/dj_printer.dart index 1e4e752..bb72385 100644 --- a/lib/dj_printer.dart +++ b/lib/dj_printer.dart @@ -1,7 +1,14 @@ import 'dart:async'; +import 'dart:convert'; +import 'dart:typed_data'; +import 'dart:ui'; +import 'package:barcode_widget/barcode_widget.dart'; import 'package:dj_printer/src/status_enum.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_image_compress/flutter_image_compress.dart'; +import 'package:widget_to_image/widget_to_image.dart'; class DjPrinter { static late final DjPrinter _instance = DjPrinter._(); @@ -133,4 +140,369 @@ class DjPrinter { }); return res; } + + Future printAScodeByImg({required String code, + required String channel, + required String country, + required String num, + required String sum, + required String countStr, + required int offset, + required bool hasPlan}) async { + + + ByteData bDCode = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getCode(code), + ), + ),pixelRatio: window.devicePixelRatio,size: const Size(25,240)); + + Uint8List uint8ListCode = await testComporessList(bDCode); + + + ByteData bDChannel = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getChannel(channel) + ), + ),pixelRatio: window.devicePixelRatio,size: const Size(40,140)); + + Uint8List uint8ListChannel = await testComporessList(bDChannel); + + + ByteData bDNum = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getNum(num) + ), + ),pixelRatio: window.devicePixelRatio,size: Size(20,(20*num.length).toDouble())); + + Uint8List uint8ListNum = await testComporessList(bDNum); + + + ByteData bDSum = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getNum(sum) + ), + ),pixelRatio: window.devicePixelRatio,size: Size(20,(20*sum.length).toDouble())); + + Uint8List uint8ListSum= await testComporessList(bDSum); + + + Uint8List uint8ListCountry; + if(hasPlan){ + ByteData bDCountry = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getCountry(country) + ), + ),pixelRatio: window.devicePixelRatio,size: Size(country.length>4?44: 22,70)); + + uint8ListCountry = await testComporessList(bDCountry); + }else{ + ByteData bDCountry = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getNoplan() + ), + ),pixelRatio: window.devicePixelRatio,size: const Size(22,100)); + + uint8ListCountry = await testComporessList(bDCountry); + } + + + + ByteData bDBarCode = await WidgetToImage.widgetToImage( Directionality( + textDirection: TextDirection.ltr, + child: Material( + child:_getBarCode(code) + ), + ),pixelRatio: window.devicePixelRatio,size: const Size(60,120)); + + Uint8List uint8ListBarCode = await testComporessList(bDBarCode); + + final res = await _channel.invokeMethod('print', { + 'code': code, + 'channel': channel, + 'country': country, + 'countStr': countStr, + 'offset': offset, + 'hasPlan': hasPlan, + 'byteCode': uint8ListCode, + 'bytesChannel':uint8ListChannel, + 'bytesCountry':uint8ListCountry, + 'bytesBarCode':uint8ListBarCode, + 'bytesSum':uint8ListSum, + 'bytesNum':uint8ListNum, + }); + return res; + } + + Future testComporessList(ByteData data) async { + + final buffer = data.buffer; + + var result = await FlutterImageCompress.compressWithList( + buffer.asUint8List(), + quality: 1, + + ); + print(buffer.asUint8List().length); + print(result.length); + return result; + } + + + Widget _getCountry(String country){ + return RotatedBox( + quarterTurns: 1, + child: Text( + country, + maxLines: 2, + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.black, + fontSize: 17, + fontWeight: FontWeight.bold, + ), + ), + ); + } + + + Widget _getNoplan(){ + return RotatedBox( + quarterTurns: 1, + child: Text( + '未 建 计 划', + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.black, + fontSize: 17, + fontWeight: FontWeight.bold, + ), + ), + ); + } + + + Widget _getNum(String num){ + return RotatedBox( + quarterTurns: 1, + child: Text( + num, + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.black, + fontSize: 17, + fontWeight: FontWeight.bold, + ), + ), + ); + } + + + + Widget _getChannel(String channel){ + return RotatedBox( + quarterTurns: 1, + child: Text( + channel, + maxLines: 2, + style: const TextStyle( + color: Colors.black, + fontSize: 13, + ), + ), + ); + } + + + + + Widget _getCode(String code){ + return RotatedBox( + quarterTurns: 1, + child: Text( + code, + style: const TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.bold), + ), + ); + } + + + Widget _getBarCode(String code){ + return RotatedBox( + quarterTurns: 1, + child: BarcodeWidget( + barcode: Barcode.code128(), + data: code, + style: TextStyle( + fontSize: 10 + ), + ), + ); + } + + Widget _getCard(String code, String channel, String country, String countStr, + int offset, bool hasPlan) { + return RotatedBox( + quarterTurns: 3, + child: Text( + code, + style: const TextStyle( + color: Colors.black, + fontSize: 15, + ), + ), + ); + + + Container( + //margin: EdgeInsets.all(5), + width: 700 / 3.7, + height: 950 / 3.7, + // decoration: BoxDecoration( + // color: Colors.white, + // border: Border.all(color: Colors.black, width: 0.5)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 197 / 3.7, + height: 950 / 3.7, + // decoration: BoxDecoration( + // color: Colors.white, + // border: Border( + // right: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + alignment: Alignment.center, + child: RotatedBox( + quarterTurns: 3, + child: Text( + code, + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.bold), + ), + ), + ), + Container( + width: 215 / 3.7, + height: 950 / 3.7, + // decoration: BoxDecoration( + // border: Border( + // right: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + alignment: Alignment.center, + // child: Column( + // children: [ + // Container( + // width: 215 / 3.7, + // height: 950 / 3.7 / 3, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // country, + // style: TextStyle( + // color: Colors.black, + // fontSize: 17, + // fontWeight: FontWeight.bold), + // ), + // ), + // ), + // Container( + // width: 215 / 3.7, + // height: 950 / 3.7 / 3 * 2 - 4, + // padding: EdgeInsets.symmetric(vertical: 10), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // channel, + // style: TextStyle( + // color: Colors.black, + // fontSize: 15, + // ), + // ), + // ), + // ) + // ], + // ) + ), + Container( + width: 358 / 3.7 -30, + height: 950 / 3.7, + alignment: Alignment.center, + child: Column( + children: [ + // Container( + // width: 358 / 3.7 -20, + // height: 950 / 3.7 / 3, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Colors.black, + // width: 0.5, + // )), + // ), + // alignment: Alignment.center, + // child: RotatedBox( + // quarterTurns: 3, + // child: Text( + // countStr, + // style: TextStyle( + // color: Colors.black, + // fontSize: 17, + // fontWeight: FontWeight.bold), + // ), + // ), + // ), + // Container( + // width: 358 / 3.7 -30, + // height: 950 / 3.7 / 3 * 2 - 1.5, + // padding: EdgeInsets.only(left: 15,top: 15,bottom: 15,right: 10) , + // child: RotatedBox( + // quarterTurns: 3, + // child: BarcodeWidget( + // + // barcode: Barcode.code128(), + // data: code, + // style: TextStyle( + // fontSize: 10 + // ), + // ), + // ), + // ) + ], + )), + ], + ), + ); + + + + } + + } diff --git a/pubspec.lock b/pubspec.lock index d4b1f47..e7fbfdb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,49 +5,63 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.8.2" + barcode: + dependency: transitive + description: + name: barcode + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + barcode_widget: + dependency: "direct main" + description: + name: barcode_widget + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.16.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" flutter: @@ -55,11 +69,18 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_image_compress: + dependency: "direct main" + description: + name: flutter_image_compress + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.4" flutter_test: @@ -71,37 +92,44 @@ packages: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.12.11" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.1.4" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.7.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.8.1" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" sky_engine: dependency: transitive description: flutter @@ -111,51 +139,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.4.9" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.2" + widget_to_image: + dependency: "direct main" + description: + name: widget_to_image + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" sdks: dart: ">=2.17.0-0 <3.0.0" - flutter: ">=1.20.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index c2b0133..687108c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,11 +11,16 @@ dependencies: flutter: sdk: flutter + widget_to_image: ^2.0.0 + barcode_widget: ^2.0.2 + flutter_image_compress: ^1.1.0 + dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^1.0.0 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec