2023-10-20 13:49:23 +08:00
|
|
|
|
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
|
|
|
|
|
|
|
|
|
import 'jc_printer_method_channel.dart';
|
|
|
|
|
|
|
|
|
|
abstract class JcPrinterPlatform extends PlatformInterface {
|
|
|
|
|
/// Constructs a JcPrinterPlatform.
|
|
|
|
|
JcPrinterPlatform() : super(token: _token);
|
|
|
|
|
|
|
|
|
|
static final Object _token = Object();
|
|
|
|
|
|
|
|
|
|
static JcPrinterPlatform _instance = MethodChannelJcPrinter();
|
|
|
|
|
|
|
|
|
|
/// The default instance of [JcPrinterPlatform] to use.
|
|
|
|
|
///
|
|
|
|
|
/// Defaults to [MethodChannelJcPrinter].
|
|
|
|
|
static JcPrinterPlatform get instance => _instance;
|
|
|
|
|
|
|
|
|
|
/// Platform-specific implementations should set this with their own
|
|
|
|
|
/// platform-specific class that extends [JcPrinterPlatform] when
|
|
|
|
|
/// they register themselves.
|
|
|
|
|
static set instance(JcPrinterPlatform instance) {
|
|
|
|
|
PlatformInterface.verifyToken(instance, _token);
|
|
|
|
|
_instance = instance;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-24 15:20:03 +08:00
|
|
|
|
/// 蓝牙连接指定名称的打印机。
|
|
|
|
|
///
|
|
|
|
|
/// @param name 要连接的蓝牙打印机的名称。
|
|
|
|
|
Future<void> connect(String name) async {
|
|
|
|
|
throw UnimplementedError('connect() has not been implemented.');
|
2023-10-20 13:49:23 +08:00
|
|
|
|
}
|
2023-10-20 17:45:24 +08:00
|
|
|
|
|
2023-10-24 15:20:03 +08:00
|
|
|
|
/// 断开连接
|
|
|
|
|
Future<void> disconnect() async {
|
|
|
|
|
throw UnimplementedError('disconnect() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 设置总打印机张数
|
|
|
|
|
Future<void> setTotalPrints(int page) async {
|
|
|
|
|
throw UnimplementedError('setTotalPrints() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 初始化画板。
|
|
|
|
|
///
|
|
|
|
|
/// @param width 画布宽度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param height 画布高度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param horizontalShift 水平偏移,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param verticalShift 竖直偏移,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param rotate 旋转角度,支持角度0/90/180/270。
|
|
|
|
|
///
|
|
|
|
|
/// @param font 使用字体路径。
|
|
|
|
|
Future<void> initDrawingBoard({
|
|
|
|
|
required double width,
|
|
|
|
|
required double height,
|
|
|
|
|
required String font,
|
|
|
|
|
double horizontalShift = 0,
|
|
|
|
|
double verticalShift = 0,
|
|
|
|
|
int rotate = 0,
|
|
|
|
|
}) async {
|
|
|
|
|
throw UnimplementedError('initDrawingBoard() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 绘制图片。
|
|
|
|
|
///
|
|
|
|
|
/// @param x 水平坐标,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param y 垂直坐标,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param width 图片宽度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param height 图片高度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param base64 图像base64数据。
|
|
|
|
|
///
|
|
|
|
|
/// @param rotate 旋转角度,支持角度0/90/180/270。
|
|
|
|
|
///
|
|
|
|
|
/// @param type 处理算法,默认1即可。
|
|
|
|
|
///
|
|
|
|
|
/// @param threshold 阈值,默认127即可。
|
|
|
|
|
Future<bool> drawLabelImage({
|
|
|
|
|
required double x,
|
|
|
|
|
required double y,
|
|
|
|
|
required double width,
|
|
|
|
|
required double height,
|
|
|
|
|
required String base64,
|
|
|
|
|
int rotate = 0,
|
|
|
|
|
int type = 1,
|
|
|
|
|
double threshold = 127,
|
|
|
|
|
}) async {
|
|
|
|
|
throw UnimplementedError('drawLabelImage() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 绘制文本。
|
|
|
|
|
///
|
|
|
|
|
/// @param x 水平坐标,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param y 垂直坐标,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param width 图片宽度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param height 图片高度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param content 内容。
|
|
|
|
|
///
|
|
|
|
|
/// @param rotate 旋转角度,支持角度0/90/180/270。
|
|
|
|
|
///
|
|
|
|
|
/// @param textAlignHorizontal 文本水平对齐方式 0 左对齐、1 水平居中对齐、2 右对齐。
|
|
|
|
|
///
|
|
|
|
|
/// @param textAlignVertical 文本竖直对齐方式 0 上对齐、1 垂直居中对齐、2 下对齐。
|
|
|
|
|
///
|
|
|
|
|
/// @param lineMode 换行方式
|
|
|
|
|
/// 1:宽高固定,内容大小自适应(字号/字符间距/行间距 按比例缩放)
|
|
|
|
|
/// 2:宽度固定,高度自适应
|
|
|
|
|
/// 6.宽高固定,内容超过预设的宽高时自动缩小。
|
|
|
|
|
///
|
|
|
|
|
/// @param letterSpacing 字体间隔。
|
|
|
|
|
///
|
|
|
|
|
/// @param lineSpacing 行间隔。
|
|
|
|
|
Future<bool> drawLabelText({
|
|
|
|
|
required double x,
|
|
|
|
|
required double y,
|
|
|
|
|
required double width,
|
|
|
|
|
required double height,
|
|
|
|
|
required String content,
|
|
|
|
|
required double fontSize,
|
|
|
|
|
int rotate = 0,
|
|
|
|
|
int textAlignHorizontal = 0,
|
|
|
|
|
int textAlignVertical = 0,
|
|
|
|
|
int lineMode = 1,
|
|
|
|
|
double letterSpacing = 0,
|
|
|
|
|
double lineSpacing = 0,
|
|
|
|
|
}) async {
|
|
|
|
|
throw UnimplementedError('drawLabelText() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 绘制条码。
|
|
|
|
|
///
|
|
|
|
|
/// @param x 水平坐标,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param y 垂直坐标,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param width 图片宽度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param height 图片高度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param text 内容。
|
|
|
|
|
///
|
|
|
|
|
/// @param fontSize 字体大小。
|
|
|
|
|
///
|
|
|
|
|
/// @param rotate 旋转角度,支持角度0/90/180/270。
|
|
|
|
|
///
|
|
|
|
|
/// @param textHeight 文本高度,单位mm。
|
|
|
|
|
///
|
|
|
|
|
/// @param textPosition 文本位置,一维码文字识别码显示位置
|
|
|
|
|
/// 0:下方显示
|
|
|
|
|
/// 1:上方显示
|
|
|
|
|
/// 2:不显示。
|
|
|
|
|
///
|
|
|
|
|
/// @param codeType 一维码类型
|
|
|
|
|
/// 20:CODE128
|
|
|
|
|
/// 21:UPC-A
|
|
|
|
|
/// 22:UPC-E
|
|
|
|
|
/// 23:EAN8
|
|
|
|
|
/// 24:EAN13
|
|
|
|
|
/// 25:CODE93
|
|
|
|
|
/// 26:CODE39
|
|
|
|
|
/// 27:CODEBAR
|
|
|
|
|
/// 28:ITF25。
|
|
|
|
|
Future<bool> drawLabelBarcode({
|
|
|
|
|
required double x,
|
|
|
|
|
required double y,
|
|
|
|
|
required double width,
|
|
|
|
|
required double height,
|
|
|
|
|
required String text,
|
|
|
|
|
required double textHeight,
|
|
|
|
|
required double fontSize,
|
|
|
|
|
int rotate = 0,
|
|
|
|
|
int codeType = 20,
|
|
|
|
|
int textPosition = 0,
|
2023-11-25 13:55:51 +08:00
|
|
|
|
}) {
|
2023-10-24 15:20:03 +08:00
|
|
|
|
throw UnimplementedError('drawLabelBarcode() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 获取画板上绘制的数据
|
|
|
|
|
Future<String> getLabelData() async {
|
|
|
|
|
throw UnimplementedError('getLabelData() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 开始打印任务
|
|
|
|
|
///
|
|
|
|
|
/// @param blackRules 设置打印浓度。
|
|
|
|
|
///
|
|
|
|
|
/// @param paperStyle 设置纸张类型。
|
|
|
|
|
Future<bool> startJob({
|
|
|
|
|
required int blackRules,
|
|
|
|
|
required int paperStyle,
|
|
|
|
|
}) async {
|
|
|
|
|
throw UnimplementedError('startJob() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-25 13:55:51 +08:00
|
|
|
|
/// 取消打印任务
|
|
|
|
|
Future<bool> cancelJob() async {
|
|
|
|
|
throw UnimplementedError('endJob() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 结束当前打印任务
|
|
|
|
|
Future<bool> endPrint() async {
|
2023-10-24 15:20:03 +08:00
|
|
|
|
throw UnimplementedError('endJob() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 提交打印任务
|
|
|
|
|
///
|
|
|
|
|
/// @param data 打印数据。
|
|
|
|
|
///
|
|
|
|
|
/// @param count 用于指定当前页的打印份数。
|
|
|
|
|
Future<bool> commit({
|
|
|
|
|
required String data,
|
|
|
|
|
int count = 1,
|
|
|
|
|
}) async {
|
|
|
|
|
throw UnimplementedError('commit() has not been implemented.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 打印机事件流
|
|
|
|
|
Stream<dynamic> get printerStream {
|
|
|
|
|
throw UnimplementedError('printerStream has not been implemented.');
|
2023-10-20 17:45:24 +08:00
|
|
|
|
}
|
2023-10-20 13:49:23 +08:00
|
|
|
|
}
|