更改名称

master
张萌 2 years ago
parent 3d16fd8ee1
commit 81e0daf448

@ -0,0 +1,204 @@
<component name="libraryTable">
<library name="Dart Packages" type="DartPackagesLibraryType">
<properties>
<option name="packageNameToDirsMap">
<entry key="async">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/async-2.9.0/lib" />
</list>
</value>
</entry>
<entry key="boolean_selector">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib" />
</list>
</value>
</entry>
<entry key="bot_toast">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/bot_toast-4.0.3/lib" />
</list>
</value>
</entry>
<entry key="characters">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/characters-1.2.1/lib" />
</list>
</value>
</entry>
<entry key="clock">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/clock-1.1.1/lib" />
</list>
</value>
</entry>
<entry key="collection">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/collection-1.16.0/lib" />
</list>
</value>
</entry>
<entry key="cupertino_icons">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/cupertino_icons-1.0.5/lib" />
</list>
</value>
</entry>
<entry key="fake_async">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/fake_async-1.3.1/lib" />
</list>
</value>
</entry>
<entry key="flutter">
<value>
<list>
<option value="$PROJECT_DIR$/../fvm/versions/3.3.0/packages/flutter/lib" />
</list>
</value>
</entry>
<entry key="flutter_lints">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/flutter_lints-1.0.4/lib" />
</list>
</value>
</entry>
<entry key="flutter_test">
<value>
<list>
<option value="$PROJECT_DIR$/../fvm/versions/3.3.0/packages/flutter_test/lib" />
</list>
</value>
</entry>
<entry key="lints">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/lints-1.0.1/lib" />
</list>
</value>
</entry>
<entry key="matcher">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/matcher-0.12.12/lib" />
</list>
</value>
</entry>
<entry key="material_color_utilities">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/material_color_utilities-0.1.5/lib" />
</list>
</value>
</entry>
<entry key="meta">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/meta-1.8.0/lib" />
</list>
</value>
</entry>
<entry key="path">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/path-1.8.2/lib" />
</list>
</value>
</entry>
<entry key="sky_engine">
<value>
<list>
<option value="$PROJECT_DIR$/../fvm/versions/3.3.0/bin/cache/pkg/sky_engine/lib" />
</list>
</value>
</entry>
<entry key="source_span">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/source_span-1.9.0/lib" />
</list>
</value>
</entry>
<entry key="stack_trace">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib" />
</list>
</value>
</entry>
<entry key="stream_channel">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib" />
</list>
</value>
</entry>
<entry key="string_scanner">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.1/lib" />
</list>
</value>
</entry>
<entry key="term_glyph">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.1/lib" />
</list>
</value>
</entry>
<entry key="test_api">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/test_api-0.4.12/lib" />
</list>
</value>
</entry>
<entry key="vector_math">
<value>
<list>
<option value="$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.2/lib" />
</list>
</value>
</entry>
</option>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/async-2.9.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/bot_toast-4.0.3/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/characters-1.2.1/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/clock-1.1.1/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/collection-1.16.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/cupertino_icons-1.0.5/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/fake_async-1.3.1/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/flutter_lints-1.0.4/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/lints-1.0.1/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/matcher-0.12.12/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/material_color_utilities-0.1.5/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/meta-1.8.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/path-1.8.2/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/source_span-1.9.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.1/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.1/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/test_api-0.4.12/lib" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.2/lib" />
<root url="file://$PROJECT_DIR$/../fvm/versions/3.3.0/bin/cache/pkg/sky_engine/lib" />
<root url="file://$PROJECT_DIR$/../fvm/versions/3.3.0/packages/flutter/lib" />
<root url="file://$PROJECT_DIR$/../fvm/versions/3.3.0/packages/flutter_test/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -1,8 +1,6 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Flutter Plugins" type="FlutterPluginsLibraryType"> <library name="Flutter Plugins" type="FlutterPluginsLibraryType">
<CLASSES> <CLASSES />
<root url="file://$PROJECT_DIR$" />
</CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />
</library> </library>

@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hy_printer/device.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/hy_printer.dart';
import 'package:hy_printer_example/scan_page.dart'; import 'package:hy_printer_example/scan_page.dart';
// import 'package:permission_handler/permission_handler.dart'; // import 'package:permission_handler/permission_handler.dart';
@ -30,8 +30,8 @@ class _MyAppState extends State<MyApp> {
Future<void> initPlatformState() async { Future<void> initPlatformState() async {
DjPrinter().init(); HyPrinter().init();
DjPrinter().addDiscoveryListen(onReceive: (data) { HyPrinter().addDiscoveryListen(onReceive: (data) {
var js = json.decode(data.toString()); var js = json.decode(data.toString());
if ((js['name'] as String).startsWith('HM')) { if ((js['name'] as String).startsWith('HM')) {
devices.add(Device( devices.add(Device(
@ -44,10 +44,10 @@ class _MyAppState extends State<MyApp> {
print("————————————————————————"); print("————————————————————————");
}, onFinish: () { }, onFinish: () {
print('——————————————————————————————'); print('——————————————————————————————');
DjPrinter().cancelDiscovery(); HyPrinter().cancelDiscovery();
cancel(); cancel();
}); });
DjPrinter().addConnectListen(onConnect: () { HyPrinter().addConnectListen(onConnect: () {
print("connected"); print("connected");
}, onDisconnect: () { }, onDisconnect: () {
print('disconnected'); print('disconnected');
@ -82,7 +82,7 @@ class _MyAppState extends State<MyApp> {
BotToast.showLoading(wrapToastAnimation: (controller, func, child) { BotToast.showLoading(wrapToastAnimation: (controller, func, child) {
return discoveryLoadingWidget(); return discoveryLoadingWidget();
}); });
DjPrinter().startSearch; HyPrinter().startSearch;
}, },
child: const Text('扫描设备')), child: const Text('扫描设备')),
// TextButton(onPressed: () {}, child: const Text('打印')), // TextButton(onPressed: () {}, child: const Text('打印')),
@ -97,7 +97,7 @@ class _MyAppState extends State<MyApp> {
}); });
await DjPrinter().connect(e.address).then((value) { await HyPrinter().connect(e.address).then((value) {
print("main value result"); print("main value result");
print(value); print(value);
if(value!=null&&value){ if(value!=null&&value){
@ -124,7 +124,7 @@ class _MyAppState extends State<MyApp> {
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().printNewAScode( HyPrinter().printNewAScode(
code: 'ASSZ000000002', code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001', barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送', channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@ -138,7 +138,7 @@ class _MyAppState extends State<MyApp> {
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().printNewAScode( HyPrinter().printNewAScode(
code: 'ASSZ000000002', code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001', barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送', channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@ -154,7 +154,7 @@ class _MyAppState extends State<MyApp> {
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().disposeConnect(); HyPrinter().disposeConnect();
}, },
child: const Text('取消链接')), child: const Text('取消链接')),

@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hy_printer/device.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/hy_printer.dart';
class ScanPage extends StatefulWidget { class ScanPage extends StatefulWidget {
@ -44,8 +44,8 @@ class _ScanPageState extends State<ScanPage> {
// Permission.bluetoothConnect.request(); // Permission.bluetoothConnect.request();
// } // }
DjPrinter().init(); HyPrinter().init();
DjPrinter().addDiscoveryListen(onReceive: (data) { HyPrinter().addDiscoveryListen(onReceive: (data) {
var js = json.decode(data.toString()); var js = json.decode(data.toString());
if ((js['name'] as String).startsWith('HM')) { if ((js['name'] as String).startsWith('HM')) {
devices.add(Device( devices.add(Device(
@ -61,10 +61,10 @@ class _ScanPageState extends State<ScanPage> {
print("————————————————————————"); print("————————————————————————");
}, onFinish: () { }, onFinish: () {
print('——————————————————————————————'); print('——————————————————————————————');
DjPrinter().cancelDiscovery(); HyPrinter().cancelDiscovery();
cancel(); cancel();
}); });
DjPrinter().addConnectListen(onConnect: () { HyPrinter().addConnectListen(onConnect: () {
print("connected"); print("connected");
}, onDisconnect: () { }, onDisconnect: () {
print('disconnected'); print('disconnected');
@ -93,7 +93,7 @@ class _ScanPageState extends State<ScanPage> {
BotToast.showLoading(wrapToastAnimation: (controller, func, child) { BotToast.showLoading(wrapToastAnimation: (controller, func, child) {
return discoveryLoadingWidget(); return discoveryLoadingWidget();
}); });
DjPrinter().startSearch; HyPrinter().startSearch;
}, },
child: const Text('扫描设备')), child: const Text('扫描设备')),
// TextButton(onPressed: () {}, child: const Text('打印')), // TextButton(onPressed: () {}, child: const Text('打印')),
@ -104,7 +104,7 @@ class _ScanPageState extends State<ScanPage> {
.map((e) => TextButton( .map((e) => TextButton(
onPressed: ()async { onPressed: ()async {
await DjPrinter().connect(e.address); await HyPrinter().connect(e.address);
}, },
@ -120,7 +120,7 @@ class _ScanPageState extends State<ScanPage> {
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().printNewAScode( HyPrinter().printNewAScode(
code: 'ASSZ000000002', code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001', barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送', channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@ -134,7 +134,7 @@ class _ScanPageState extends State<ScanPage> {
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().printNewAScode( HyPrinter().printNewAScode(
code: 'ASSZ000000002', code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001', barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送', channel: '加拿大温哥华海派快线-卡派 / UPS派送',
@ -150,7 +150,7 @@ class _ScanPageState extends State<ScanPage> {
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().disposeConnect(); HyPrinter().disposeConnect();
}, },
child: const Text('取消链接')), child: const Text('取消链接')),

@ -5,65 +5,58 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2" version: "2.9.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
bot_toast: bot_toast:
dependency: "direct main" dependency: "direct main"
description: description:
name: bot_toast name: bot_toast
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.3" version: "4.0.3"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.16.0" version: "1.16.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" version: "1.0.5"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -73,7 +66,7 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_lints name: flutter_lints
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
flutter_test: flutter_test:
@ -92,37 +85,37 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.12"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.4" version: "0.1.5"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -132,49 +125,49 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2" version: "1.9.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.12"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
sdks: sdks:

@ -17,5 +17,6 @@
<orderEntry type="library" name="Dart SDK" level="project" /> <orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" /> <orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="CPCL_SDK_V1.11" level="project" /> <orderEntry type="library" name="CPCL_SDK_V1.11" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component> </component>
</module> </module>

@ -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<bool?> connect(String address) async {
final res = await _channel.invokeMethod('connect', {'address': address});
return res;
}
void disposeDiscovery() {
print('disposeDiscovery');
final res = _channel.invokeMethod('disposeDiscovery');
}
Future<bool?> disposeConnect() async {
final res = await _channel.invokeMethod('disposeConnect');
return res;
}
Future<bool?> 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<PRINT_STATUS?> 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<PRINT_STATUS?> 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<bool?> 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<bool?> 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;
}
}

@ -1,155 +1,191 @@
// import 'dart:async'; import 'dart:async';
//
// import 'package:flutter/services.dart';
// // import 'package:flutter_blue/flutter_blue.dart'; import 'package:flutter/services.dart';
// import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:hy_printer/status_enum.dart';
// import 'package:hy_printer/device.dart';
// import 'package:permission_handler/permission_handler.dart'; class HyPrinter {
// static late final HyPrinter _instance = HyPrinter._();
// class HyPrinter {
// static const MethodChannel _channel = MethodChannel('hy_printer'); HyPrinter._();
// static FlutterBluePlus flutterBlue = FlutterBluePlus.instance;
// static void init() async { factory HyPrinter() => _instance;
// var per = await Permission.bluetooth.isGranted; static const MethodChannel _channel = MethodChannel('hy_printer');
// if (!per) { static const EventChannel _deviceChannel =
// Permission.bluetooth.request(); EventChannel("com.discovery.devices");
// } StreamSubscription? _discoveryStream;
// var pers = await Permission.locationWhenInUse.isGranted;
// if (!pers) { StreamSubscription addDiscoveryListen(
// Permission.locationWhenInUse.request(); {required void Function(dynamic data) onReceive,
// } void Function()? onStart,
// } void Function()? onFinish}) {
// if (_discoveryStream == null) {
// static Future<List<Device>> getDeiveces() async { return _deviceChannel.receiveBroadcastStream().listen((data) {
// var devices = <Device>[]; if (data == "start" && onStart != null) {
// await flutterBlue.startScan(timeout: const Duration(seconds: 4)); onStart();
// flutterBlue.scanResults.listen((results) { } else if (data == "finish" && onFinish != null) {
// for (ScanResult r in results) { onFinish();
// // } else {
// if(r.device.name.contains('HM')){ onReceive(data);
// devices.add(Device(name: r.device.name, address: r.device.id.id)); }
// } });
// } else {
// // if (r.device.name.isNotEmpty) { return _discoveryStream!;
// // devices.add(Device(name: r.device.name, address: r.device.id.id)); }
// // } }
// }
// }); void cancelDiscovery() {
// await flutterBlue.stopScan(); _discoveryStream?.cancel();
// return devices; _discoveryStream = null;
// } print('结束搜索');
// disposeDiscovery();
// static Future<bool> blutIsOn() async { }
// var result = await flutterBlue.isOn;
// return result; static const EventChannel _connectChannel = EventChannel("com.connect");
// } StreamSubscription? _connectStream;
//
// ///0 StreamSubscription addConnectListen({required void Function() onConnect,
// ///-1 required void Function() onDisconnect}) {
// ///-2 if (_connectStream == null) {
// ///-3sdk return _connectChannel.receiveBroadcastStream().listen((data) {
// ///-4 if (data == 'connected') {
// static Future<int> connect(String address) async { onConnect();
// int result = -4; } else if (data == 'disconnected') {
// await Future.delayed(const Duration(milliseconds: 2000), () async { onDisconnect();
// result = await _channel.invokeMethod('connect', {'address': address}); }
// }); });
// // int result = await _channel.invokeMethod('connect', {'address': address}); } else {
// return result; return _connectStream!;
// } }
// }
// static Future<bool> disConnect() async {
// bool result = await _channel.invokeMethod('disConnect'); void cancelConnect() {
// return result; if (_connectStream != null) {
// } _connectStream!.cancel();
// _connectStream = null;
// ///0: }
// ///-1 }
// ///2
// ///3 void get startSearch {
// static Future<int> getStatus() async { final res = _channel.invokeMethod('startSearch');
// int result = await _channel.invokeMethod( }
// 'getStatus',
// ); bool _hasInit = false;
// return result;
// } bool get hasInit => _hasInit;
//
// static Future<int> printBarCode( Future<bool?> connect(String address) async {
// int direction,
// int type, final res = await _channel.invokeMethod('connect', {'address': address});
// String width, return res;
// String ratio, }
// String height,
// String x, void disposeDiscovery() {
// String y, print('disposeDiscovery');
// bool undertext, final res = _channel.invokeMethod('disposeDiscovery');
// String size, }
// String offset,
// String data, Future<bool?> disposeConnect() async {
// ) async { final res = await _channel.invokeMethod('disposeConnect');
// int result = await _channel.invokeMethod('printBarCode', { return res;
// 'direction': direction, }
// 'type': type,
// 'width': width, Future<bool?> init() async {
// 'ratio': ratio, final res = await _channel.invokeMethod('init');
// 'height': height, _hasInit = true;
// 'x': x, return res;
// 'y': y, }
// 'undertext': undertext,
// 'size': size, //0 normal
// 'offset': offset, //1 busy
// 'data': data, //2 paper empty
// }); //4 cover open
// return result; //8 battery low
// } // Future<PRINT_STATUS?> getStatus() async {
// // final res = await _channel.invokeMethod('getStatus');
// static Future<int> printLine( // switch (res) {
// String x0, // case 0:
// String y0, // return PRINT_STATUS.normal;
// String x1, // case 1:
// String y1, // return PRINT_STATUS.busy;
// ) async { // case 2:
// int result = await _channel // return PRINT_STATUS.paperEmpty;
// .invokeMethod('printLine', {'x0': x0, 'x1': x1, 'y0': y0, 'y1': y1}); // case 4:
// return result; // return PRINT_STATUS.coverOpen;
// } // case 8:
// // return PRINT_STATUS.batteryLow;
// static Future<int> align(String align) async { // default:
// int result = await _channel.invokeMethod('align', {'align': align}); // return null;
// return result; // }
// } // }
//
// static Future<int> setBold(String bold) async {
// int result = await _channel.invokeMethod('setBold', {'bold': bold});
// return result; //0 normal
// } //-1
// //2 paper empty
// static Future<int> prefeed(String prefeed) async { //6 cover open
// int result = await _channel.invokeMethod('setBold', {'prefeed': prefeed});
// return result; Future<PRINT_STATUS?> getStatus() async {
// } final res = await _channel.invokeMethod('getStatus');
// switch (res) {
// /// 'code': code, case 0:
// // 'fbaCode': fbaCode, fba/fba return PRINT_STATUS.normal;
// // 'channel': channel, case -1:
// // 'country': country, return PRINT_STATUS.fail;
// // 'count': count, case 2:
// // 'hasPlan':hasPlan return PRINT_STATUS.paperEmpty;
// static Future<int> printAsOrder( case 6:
// {required String code, return PRINT_STATUS.coverOpen;
// required String fbaCode, default:
// required String channel, return null;
// required String country, }
// required String count, }
// required bool hasPlan}) async {
// int result = await _channel.invokeMethod('printAsOrder', { Future<bool?> printNewAScode({required String code,
// 'code': code, required String barCode,
// 'fbaCode': fbaCode, required String channel,
// 'channel': channel, required String country,
// 'country': country, required String num,
// 'count': count, required String sum,
// 'hasPlan': hasPlan required int offset,
// }); required bool hasPlan}) async {
// return result; 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<bool?> 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;
}
}

@ -5,51 +5,44 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2" version: "2.9.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.16.0" version: "1.16.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -59,7 +52,7 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_lints name: flutter_lints
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
flutter_test: flutter_test:
@ -71,37 +64,37 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.12"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.4" version: "0.1.5"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -111,49 +104,49 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2" version: "1.9.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.12"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
sdks: sdks:

Loading…
Cancel
Save