From 81e0daf44841b0c143b6d1270b352b4b007f1c5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com>
Date: Fri, 21 Oct 2022 22:00:49 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=90=8D=E7=A7=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/libraries/Dart_Packages.xml | 204 ++++++++++++++++
.idea/libraries/Flutter_Plugins.xml | 4 +-
example/lib/main.dart | 20 +-
example/lib/scan_page.dart | 20 +-
example/pubspec.lock | 73 +++---
hy_printer.iml | 1 +
lib/dj_printer.dart | 195 ----------------
lib/hy_printer.dart | 346 +++++++++++++++-------------
pubspec.lock | 69 +++---
9 files changed, 481 insertions(+), 451 deletions(-)
create mode 100644 .idea/libraries/Dart_Packages.xml
delete mode 100644 lib/dj_printer.dart
diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
new file mode 100644
index 0000000..943ee79
--- /dev/null
+++ b/.idea/libraries/Dart_Packages.xml
@@ -0,0 +1,204 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml
index 53449da..b0f6971 100644
--- a/.idea/libraries/Flutter_Plugins.xml
+++ b/.idea/libraries/Flutter_Plugins.xml
@@ -1,8 +1,6 @@
-
-
-
+
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 3c43ef4..10da8b4 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:hy_printer/device.dart';
-import 'package:hy_printer/dj_printer.dart';
+import 'package:hy_printer/hy_printer.dart';
import 'package:hy_printer/hy_printer.dart';
import 'package:hy_printer_example/scan_page.dart';
// import 'package:permission_handler/permission_handler.dart';
@@ -30,8 +30,8 @@ class _MyAppState extends State {
Future initPlatformState() async {
- DjPrinter().init();
- DjPrinter().addDiscoveryListen(onReceive: (data) {
+ HyPrinter().init();
+ HyPrinter().addDiscoveryListen(onReceive: (data) {
var js = json.decode(data.toString());
if ((js['name'] as String).startsWith('HM')) {
devices.add(Device(
@@ -44,10 +44,10 @@ class _MyAppState extends State {
print("————————————————————————");
}, onFinish: () {
print('——————————————————————————————');
- DjPrinter().cancelDiscovery();
+ HyPrinter().cancelDiscovery();
cancel();
});
- DjPrinter().addConnectListen(onConnect: () {
+ HyPrinter().addConnectListen(onConnect: () {
print("connected");
}, onDisconnect: () {
print('disconnected');
@@ -82,7 +82,7 @@ class _MyAppState extends State {
BotToast.showLoading(wrapToastAnimation: (controller, func, child) {
return discoveryLoadingWidget();
});
- DjPrinter().startSearch;
+ HyPrinter().startSearch;
},
child: const Text('扫描设备')),
// TextButton(onPressed: () {}, child: const Text('打印')),
@@ -97,7 +97,7 @@ class _MyAppState extends State {
});
- await DjPrinter().connect(e.address).then((value) {
+ await HyPrinter().connect(e.address).then((value) {
print("main value result");
print(value);
if(value!=null&&value){
@@ -124,7 +124,7 @@ class _MyAppState extends State {
),
TextButton(
onPressed: () {
- DjPrinter().printNewAScode(
+ HyPrinter().printNewAScode(
code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@@ -138,7 +138,7 @@ class _MyAppState extends State {
TextButton(
onPressed: () {
- DjPrinter().printNewAScode(
+ HyPrinter().printNewAScode(
code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@@ -154,7 +154,7 @@ class _MyAppState extends State {
),
TextButton(
onPressed: () {
- DjPrinter().disposeConnect();
+ HyPrinter().disposeConnect();
},
child: const Text('取消链接')),
diff --git a/example/lib/scan_page.dart b/example/lib/scan_page.dart
index 4a89260..595d74a 100644
--- a/example/lib/scan_page.dart
+++ b/example/lib/scan_page.dart
@@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:hy_printer/device.dart';
-import 'package:hy_printer/dj_printer.dart';
+import 'package:hy_printer/hy_printer.dart';
import 'package:hy_printer/hy_printer.dart';
class ScanPage extends StatefulWidget {
@@ -44,8 +44,8 @@ class _ScanPageState extends State {
// Permission.bluetoothConnect.request();
// }
- DjPrinter().init();
- DjPrinter().addDiscoveryListen(onReceive: (data) {
+ HyPrinter().init();
+ HyPrinter().addDiscoveryListen(onReceive: (data) {
var js = json.decode(data.toString());
if ((js['name'] as String).startsWith('HM')) {
devices.add(Device(
@@ -61,10 +61,10 @@ class _ScanPageState extends State {
print("————————————————————————");
}, onFinish: () {
print('——————————————————————————————');
- DjPrinter().cancelDiscovery();
+ HyPrinter().cancelDiscovery();
cancel();
});
- DjPrinter().addConnectListen(onConnect: () {
+ HyPrinter().addConnectListen(onConnect: () {
print("connected");
}, onDisconnect: () {
print('disconnected');
@@ -93,7 +93,7 @@ class _ScanPageState extends State {
BotToast.showLoading(wrapToastAnimation: (controller, func, child) {
return discoveryLoadingWidget();
});
- DjPrinter().startSearch;
+ HyPrinter().startSearch;
},
child: const Text('扫描设备')),
// TextButton(onPressed: () {}, child: const Text('打印')),
@@ -104,7 +104,7 @@ class _ScanPageState extends State {
.map((e) => TextButton(
onPressed: ()async {
- await DjPrinter().connect(e.address);
+ await HyPrinter().connect(e.address);
},
@@ -120,7 +120,7 @@ class _ScanPageState extends State {
),
TextButton(
onPressed: () {
- DjPrinter().printNewAScode(
+ HyPrinter().printNewAScode(
code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@@ -134,7 +134,7 @@ class _ScanPageState extends State {
TextButton(
onPressed: () {
- DjPrinter().printNewAScode(
+ HyPrinter().printNewAScode(
code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@@ -150,7 +150,7 @@ class _ScanPageState extends State {
),
TextButton(
onPressed: () {
- DjPrinter().disposeConnect();
+ HyPrinter().disposeConnect();
},
child: const Text('取消链接')),
diff --git a/example/pubspec.lock b/example/pubspec.lock
index c70fcd7..250c6ce 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -5,65 +5,58 @@ 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"
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.3"
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"
- source: hosted
- version: "1.3.1"
+ version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.1.1"
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"
fake_async:
dependency: transitive
description:
name: fake_async
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0"
+ version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
@@ -73,7 +66,7 @@ packages:
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:
@@ -92,37 +85,37 @@ 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"
+ version: "0.12.12"
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"
+ version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.7.0"
+ version: "1.8.0"
path:
dependency: transitive
description:
name: path
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.1"
+ version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
@@ -132,49 +125,49 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.2"
+ version: "1.9.0"
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"
+ version: "1.1.1"
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"
+ version: "1.2.1"
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"
+ version: "0.4.12"
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"
sdks:
diff --git a/hy_printer.iml b/hy_printer.iml
index e5eda02..ed3c5d9 100644
--- a/hy_printer.iml
+++ b/hy_printer.iml
@@ -17,5 +17,6 @@
+
\ No newline at end of file
diff --git a/lib/dj_printer.dart b/lib/dj_printer.dart
deleted file mode 100644
index 99274af..0000000
--- a/lib/dj_printer.dart
+++ /dev/null
@@ -1,195 +0,0 @@
-import 'dart:async';
-import 'dart:convert';
-import 'dart:typed_data';
-import 'dart:ui';
-
-
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:hy_printer/status_enum.dart';
-
-class DjPrinter {
- static late final DjPrinter _instance = DjPrinter._();
-
- DjPrinter._();
-
- factory DjPrinter() => _instance;
- static const MethodChannel _channel = MethodChannel('hy_printer');
- static const EventChannel _deviceChannel =
- EventChannel("com.discovery.devices");
- StreamSubscription? _discoveryStream;
-
- StreamSubscription addDiscoveryListen(
- {required void Function(dynamic data) onReceive,
- void Function()? onStart,
- void Function()? onFinish}) {
- if (_discoveryStream == null) {
- return _deviceChannel.receiveBroadcastStream().listen((data) {
- if (data == "start" && onStart != null) {
- onStart();
- } else if (data == "finish" && onFinish != null) {
- onFinish();
- } else {
- onReceive(data);
- }
- });
- } else {
- return _discoveryStream!;
- }
- }
-
- void cancelDiscovery() {
- _discoveryStream?.cancel();
- _discoveryStream = null;
- print('结束搜索');
- disposeDiscovery();
- }
-
- static const EventChannel _connectChannel = EventChannel("com.connect");
- StreamSubscription? _connectStream;
-
- StreamSubscription addConnectListen({required void Function() onConnect,
- required void Function() onDisconnect}) {
- if (_connectStream == null) {
- return _connectChannel.receiveBroadcastStream().listen((data) {
- if (data == 'connected') {
- onConnect();
- } else if (data == 'disconnected') {
- onDisconnect();
- }
- });
- } else {
- return _connectStream!;
- }
- }
-
- void cancelConnect() {
- if (_connectStream != null) {
- _connectStream!.cancel();
- _connectStream = null;
- }
- }
-
- void get startSearch {
- final res = _channel.invokeMethod('startSearch');
- }
-
- bool _hasInit = false;
-
- bool get hasInit => _hasInit;
-
- Future connect(String address) async {
-
- final res = await _channel.invokeMethod('connect', {'address': address});
- return res;
- }
-
- void disposeDiscovery() {
- print('disposeDiscovery');
- final res = _channel.invokeMethod('disposeDiscovery');
- }
-
- Future disposeConnect() async {
- final res = await _channel.invokeMethod('disposeConnect');
- return res;
- }
-
- Future init() async {
- final res = await _channel.invokeMethod('init');
- _hasInit = true;
- return res;
- }
-
- //0 normal
- //1 busy
- //2 paper empty
- //4 cover open
- //8 battery low
- // Future getStatus() async {
- // final res = await _channel.invokeMethod('getStatus');
- // switch (res) {
- // case 0:
- // return PRINT_STATUS.normal;
- // case 1:
- // return PRINT_STATUS.busy;
- // case 2:
- // return PRINT_STATUS.paperEmpty;
- // case 4:
- // return PRINT_STATUS.coverOpen;
- // case 8:
- // return PRINT_STATUS.batteryLow;
- // default:
- // return null;
- // }
- // }
-
-
-
- //0 normal
- //-1 发送失败
- //2 paper empty
- //6 cover open
-
- Future getStatus() async {
- final res = await _channel.invokeMethod('getStatus');
- switch (res) {
- case 0:
- return PRINT_STATUS.normal;
- case -1:
- return PRINT_STATUS.fail;
- case 2:
- return PRINT_STATUS.paperEmpty;
- case 6:
- return PRINT_STATUS.coverOpen;
- default:
- return null;
- }
- }
-
- Future printNewAScode({required String code,
- required String barCode,
- required String channel,
- required String country,
- required String num,
- required String sum,
- required int offset,
- required bool hasPlan}) async {
- final res = await _channel.invokeMethod('newPrint', {
- 'code': code,
- 'barCode':barCode,
- 'channel': channel,
- 'country': country,
- 'num': num,
- 'sum': sum,
- 'offset': offset,
- 'hasPlan': hasPlan,
- });
- return res;
- }
-
-
-
-
- Future printAScode({required String code,
- required String channel,
- required String country,
- required String countStr,
- required int offset,
- required bool hasPlan}) async {
- final res = await _channel.invokeMethod('print', {
- 'code': code,
- 'channel': channel,
- 'country': country,
- 'countStr': countStr,
- 'offset': offset,
- 'hasPlan': hasPlan,
- });
- return res;
- }
-
-
-
-
-
- }
-
diff --git a/lib/hy_printer.dart b/lib/hy_printer.dart
index 8b2277a..b59fb74 100644
--- a/lib/hy_printer.dart
+++ b/lib/hy_printer.dart
@@ -1,155 +1,191 @@
-// import 'dart:async';
-//
-// import 'package:flutter/services.dart';
-// // import 'package:flutter_blue/flutter_blue.dart';
-// import 'package:flutter_blue_plus/flutter_blue_plus.dart';
-// import 'package:hy_printer/device.dart';
-// import 'package:permission_handler/permission_handler.dart';
-//
-// class HyPrinter {
-// static const MethodChannel _channel = MethodChannel('hy_printer');
-// static FlutterBluePlus flutterBlue = FlutterBluePlus.instance;
-// static void init() async {
-// var per = await Permission.bluetooth.isGranted;
-// if (!per) {
-// Permission.bluetooth.request();
-// }
-// var pers = await Permission.locationWhenInUse.isGranted;
-// if (!pers) {
-// Permission.locationWhenInUse.request();
-// }
-// }
-//
-// static Future> getDeiveces() async {
-// var devices = [];
-// await flutterBlue.startScan(timeout: const Duration(seconds: 4));
-// flutterBlue.scanResults.listen((results) {
-// for (ScanResult r in results) {
-// //过滤名称为空的蓝牙
-// if(r.device.name.contains('HM')){
-// devices.add(Device(name: r.device.name, address: r.device.id.id));
-// }
-//
-// // if (r.device.name.isNotEmpty) {
-// // devices.add(Device(name: r.device.name, address: r.device.id.id));
-// // }
-// }
-// });
-// await flutterBlue.stopScan();
-// return devices;
-// }
-//
-// static Future blutIsOn() async {
-// var result = await flutterBlue.isOn;
-// return result;
-// }
-//
-// ///0:连接成功
-// ///-1:连接超时
-// ///-2:地址格式错误
-// ///-3:打印机与sdk不匹配
-// ///-4:连接失败
-// static Future connect(String address) async {
-// int result = -4;
-// await Future.delayed(const Duration(milliseconds: 2000), () async {
-// result = await _channel.invokeMethod('connect', {'address': address});
-// });
-// // int result = await _channel.invokeMethod('connect', {'address': address});
-// return result;
-// }
-//
-// static Future disConnect() async {
-// bool result = await _channel.invokeMethod('disConnect');
-// return result;
-// }
-//
-// ///0:打印机正常
-// ///-1:发送失败
-// ///2:缺纸
-// ///3:开盖
-// static Future getStatus() async {
-// int result = await _channel.invokeMethod(
-// 'getStatus',
-// );
-// return result;
-// }
-//
-// static Future printBarCode(
-// int direction,
-// int type,
-// String width,
-// String ratio,
-// String height,
-// String x,
-// String y,
-// bool undertext,
-// String size,
-// String offset,
-// String data,
-// ) async {
-// int result = await _channel.invokeMethod('printBarCode', {
-// 'direction': direction,
-// 'type': type,
-// 'width': width,
-// 'ratio': ratio,
-// 'height': height,
-// 'x': x,
-// 'y': y,
-// 'undertext': undertext,
-// 'size': size,
-// 'offset': offset,
-// 'data': data,
-// });
-// return result;
-// }
-//
-// static Future printLine(
-// String x0,
-// String y0,
-// String x1,
-// String y1,
-// ) async {
-// int result = await _channel
-// .invokeMethod('printLine', {'x0': x0, 'x1': x1, 'y0': y0, 'y1': y1});
-// return result;
-// }
-//
-// static Future align(String align) async {
-// int result = await _channel.invokeMethod('align', {'align': align});
-// return result;
-// }
-//
-// static Future setBold(String bold) async {
-// int result = await _channel.invokeMethod('setBold', {'bold': bold});
-// return result;
-// }
-//
-// static Future prefeed(String prefeed) async {
-// int result = await _channel.invokeMethod('setBold', {'prefeed': prefeed});
-// return result;
-// }
-//
-// /// 'code': code, 箱号
-// // 'fbaCode': fbaCode, fba号/非fba传空字符串
-// // 'channel': channel,渠道名称
-// // 'country': country,目的国
-// // 'count': count,货件数量
-// // 'hasPlan':hasPlan 有无计划
-// static Future printAsOrder(
-// {required String code,
-// required String fbaCode,
-// required String channel,
-// required String country,
-// required String count,
-// required bool hasPlan}) async {
-// int result = await _channel.invokeMethod('printAsOrder', {
-// 'code': code,
-// 'fbaCode': fbaCode,
-// 'channel': channel,
-// 'country': country,
-// 'count': count,
-// 'hasPlan': hasPlan
-// });
-// return result;
-// }
-// }
+import 'dart:async';
+
+
+import 'package:flutter/services.dart';
+import 'package:hy_printer/status_enum.dart';
+
+class HyPrinter {
+ static late final HyPrinter _instance = HyPrinter._();
+
+ HyPrinter._();
+
+ factory HyPrinter() => _instance;
+ static const MethodChannel _channel = MethodChannel('hy_printer');
+ static const EventChannel _deviceChannel =
+ EventChannel("com.discovery.devices");
+ StreamSubscription? _discoveryStream;
+
+ StreamSubscription addDiscoveryListen(
+ {required void Function(dynamic data) onReceive,
+ void Function()? onStart,
+ void Function()? onFinish}) {
+ if (_discoveryStream == null) {
+ return _deviceChannel.receiveBroadcastStream().listen((data) {
+ if (data == "start" && onStart != null) {
+ onStart();
+ } else if (data == "finish" && onFinish != null) {
+ onFinish();
+ } else {
+ onReceive(data);
+ }
+ });
+ } else {
+ return _discoveryStream!;
+ }
+ }
+
+ void cancelDiscovery() {
+ _discoveryStream?.cancel();
+ _discoveryStream = null;
+ print('结束搜索');
+ disposeDiscovery();
+ }
+
+ static const EventChannel _connectChannel = EventChannel("com.connect");
+ StreamSubscription? _connectStream;
+
+ StreamSubscription addConnectListen({required void Function() onConnect,
+ required void Function() onDisconnect}) {
+ if (_connectStream == null) {
+ return _connectChannel.receiveBroadcastStream().listen((data) {
+ if (data == 'connected') {
+ onConnect();
+ } else if (data == 'disconnected') {
+ onDisconnect();
+ }
+ });
+ } else {
+ return _connectStream!;
+ }
+ }
+
+ void cancelConnect() {
+ if (_connectStream != null) {
+ _connectStream!.cancel();
+ _connectStream = null;
+ }
+ }
+
+ void get startSearch {
+ final res = _channel.invokeMethod('startSearch');
+ }
+
+ bool _hasInit = false;
+
+ bool get hasInit => _hasInit;
+
+ Future connect(String address) async {
+
+ final res = await _channel.invokeMethod('connect', {'address': address});
+ return res;
+ }
+
+ void disposeDiscovery() {
+ print('disposeDiscovery');
+ final res = _channel.invokeMethod('disposeDiscovery');
+ }
+
+ Future disposeConnect() async {
+ final res = await _channel.invokeMethod('disposeConnect');
+ return res;
+ }
+
+ Future init() async {
+ final res = await _channel.invokeMethod('init');
+ _hasInit = true;
+ return res;
+ }
+
+ //0 normal
+ //1 busy
+ //2 paper empty
+ //4 cover open
+ //8 battery low
+ // Future getStatus() async {
+ // final res = await _channel.invokeMethod('getStatus');
+ // switch (res) {
+ // case 0:
+ // return PRINT_STATUS.normal;
+ // case 1:
+ // return PRINT_STATUS.busy;
+ // case 2:
+ // return PRINT_STATUS.paperEmpty;
+ // case 4:
+ // return PRINT_STATUS.coverOpen;
+ // case 8:
+ // return PRINT_STATUS.batteryLow;
+ // default:
+ // return null;
+ // }
+ // }
+
+
+
+ //0 normal
+ //-1 发送失败
+ //2 paper empty
+ //6 cover open
+
+ Future getStatus() async {
+ final res = await _channel.invokeMethod('getStatus');
+ switch (res) {
+ case 0:
+ return PRINT_STATUS.normal;
+ case -1:
+ return PRINT_STATUS.fail;
+ case 2:
+ return PRINT_STATUS.paperEmpty;
+ case 6:
+ return PRINT_STATUS.coverOpen;
+ default:
+ return null;
+ }
+ }
+
+ Future printNewAScode({required String code,
+ required String barCode,
+ required String channel,
+ required String country,
+ required String num,
+ required String sum,
+ required int offset,
+ required bool hasPlan}) async {
+ final res = await _channel.invokeMethod('newPrint', {
+ 'code': code,
+ 'barCode':barCode,
+ 'channel': channel,
+ 'country': country,
+ 'num': num,
+ 'sum': sum,
+ 'offset': offset,
+ 'hasPlan': hasPlan,
+ });
+ return res;
+ }
+
+
+
+
+ Future printAScode({required String code,
+ required String channel,
+ required String country,
+ required String countStr,
+ required int offset,
+ required bool hasPlan}) async {
+ final res = await _channel.invokeMethod('print', {
+ 'code': code,
+ 'channel': channel,
+ 'country': country,
+ 'countStr': countStr,
+ 'offset': offset,
+ 'hasPlan': hasPlan,
+ });
+ return res;
+ }
+
+
+
+
+
+ }
+
diff --git a/pubspec.lock b/pubspec.lock
index a5f87ad..0d2cd62 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -5,51 +5,44 @@ 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"
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"
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"
- source: hosted
- version: "1.3.1"
+ version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0"
+ version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
@@ -59,7 +52,7 @@ packages:
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:
@@ -71,37 +64,37 @@ 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"
+ version: "0.12.12"
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"
+ version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.7.0"
+ version: "1.8.0"
path:
dependency: transitive
description:
name: path
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.1"
+ version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
@@ -111,49 +104,49 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.2"
+ version: "1.9.0"
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"
+ version: "1.1.1"
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"
+ version: "1.2.1"
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"
+ version: "0.4.12"
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"
sdks: