print mode change to black mark from gap(label)

master
张萌 2 years ago
parent d3cb7573e4
commit 917ad90f9d

@ -2,7 +2,6 @@
<library name="Flutter Plugins" type="FlutterPluginsLibraryType">
<CLASSES>
<root url="file://$PROJECT_DIR$" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress-1.1.0" />
</CLASSES>
<JAVADOC />
<SOURCES />

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -5,9 +5,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="2f8e3712-04e2-429a-bcea-c8db1a54008e" name="默认变更列表" comment="">
<change beforePath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/runConfigurations.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/dj_printer.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/dj_printer.dart" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -33,12 +37,12 @@
</file-type-list>
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/example/pubspec.yaml" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/Blutooth.java" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/lib/dj_printer.dart" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/example/lib/main.dart" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/example/pubspec.yaml" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/lib/dj_printer.dart" root0="SKIP_INSPECTION" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
@ -59,16 +63,13 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="dart.analysis.tool.window.visible" value="false" />
<property name="io.flutter.reload.alreadyRun" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"dart.analysis.tool.window.visible": "false",
"io.flutter.reload.alreadyRun": "true",
"show.migrate.to.gradle.popup": "false"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
@ -96,7 +97,6 @@
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />

@ -80,7 +80,7 @@ public class AsPrint {
channelY = 460;channelX = 220 - channel.length()*10;
}
cpclPrinter.setForm(0, 203, 203, 800, 575, 0, 1);
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
cpclPrinter.setMedia(CPCLConst.LK_CPCL_BLACKMARK);
cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER);
cpclPrinter.printBox(0, 10, 575, 790, 3);
cpclPrinter.printLine(0, 160, 570, 160, 3);

@ -94,6 +94,8 @@ class _MyAppState extends State<MyApp> {
),
TextButton(
onPressed: () {
int i=0;
while ( i<10){
DjPrinter().printNewAScode(
code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001',
@ -102,7 +104,7 @@ class _MyAppState extends State<MyApp> {
num: '2',
sum:'9',
offset: 0,
hasPlan: false, );
hasPlan: true, );i++;}
},
child: const Text('打印')),

@ -5,70 +5,70 @@ packages:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
barcode:
dependency: transitive
description:
name: barcode
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
barcode_widget:
dependency: "direct main"
description:
name: barcode_widget
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
bot_toast:
dependency: "direct main"
description:
name: bot_toast
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
dj_printer:
@ -82,7 +82,7 @@ packages:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
flutter:
@ -94,14 +94,14 @@ packages:
dependency: transitive
description:
name: flutter_image_compress
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_test:
@ -113,84 +113,84 @@ packages:
dependency: transitive
description:
name: lints
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "9.2.0"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.2+1"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.4"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
qr:
dependency: transitive
description:
name: qr
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
sky_engine:
@ -202,56 +202,56 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
widget_to_image:
dependency: "direct main"
description:
name: widget_to_image
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
sdks:

@ -3,12 +3,9 @@ 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._();
@ -175,109 +172,109 @@ class DjPrinter {
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;
//
// 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<Uint8List> testComporessList(ByteData data) async {
// Future<Uint8List> 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;
}
// 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){
@ -361,18 +358,18 @@ class DjPrinter {
}
Widget _getBarCode(String code){
return RotatedBox(
quarterTurns: 1,
child: BarcodeWidget(
barcode: Barcode.code128(),
data: code,
style: TextStyle(
fontSize: 10
),
),
);
}
// 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) {

Loading…
Cancel
Save