Flutter条码打印机控制插件argox_printer的使用
Flutter条码打印机控制插件argox_printer的使用
Argox Printer
Flutter包通过FFI(Foreign Function Interface)来使用Argox标签打印机。
特性
- 完整集成Argox标签打印机
- 目前在OS-2140打印机的PPLA驱动上进行了测试
开始使用
要开始使用此插件,需要将argox_printer
作为依赖项添加到你的pubspec.yaml
文件中。
使用
要使用该插件,请将其作为依赖项添加到你的pubspec.yaml
文件中:
dependencies:
argox_printer: ^版本号
然后运行flutter pub get
来获取依赖项。
示例
以下是一些小示例,展示了如何使用该驱动程序。
示例代码
import 'package:flutter/material.dart';
import 'package:argox_printer/argox_printer.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
[@override](/user/override)
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final ArgoxPPLA _printer = ArgoxPPLA();
[@override](/user/override)
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Printer sample'),
),
body: Center(
child: TextButton(
child: const Icon(Icons.print),
onPressed: () async {
try {
// 创建打印对象并指定输出文件
await _printer.A_CreatePrn(0, 'test\\output.log');
// 启用调试对话框
await _printer.A_Set_DebugDialog(1);
// 设置单位为毫米
await _printer.A_Set_Unit('m');
// 清除内存
await _printer.A_Clear_Memory();
// 打印文本
await _printer.A_Prn_Text(
10, // x坐标
10, // y坐标
1, // 字体大小
2, // 行间距
0, // 水平对齐方式
1, // 垂直对齐方式
1, // 字体类型
'N', // 编码
2, // 行数
'Lorem ipsum' // 文本内容
);
// 打印条形码
await _printer.A_Prn_Barcode(
10, // x坐标
40, // y坐标
1, // 条形码类型
'A', // 编码
0, // 方向
0, // 校验位
20, // 高度
'B', // 条形码类型
1, // 宽度
'1234' // 数据
);
// 执行打印
await _printer.A_Print_Out(1, 1, 2, 1);
// 关闭打印对象
await _printer.A_ClosePrn();
} on ArgoxException catch (e) {
print('Error occurred: ${e.message}');
}
},
),
),
),
);
}
}
更多关于Flutter条码打印机控制插件argox_printer的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复