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>
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in new issue