【发布时间】:2021-05-02 07:58:24
【问题描述】:
【问题讨论】:
标签: flutter posprinter
【问题讨论】:
标签: flutter posprinter
我有相同的设备,我已经构建了颤振应用程序,并遇到了同样的问题。 我联系了公司,他们为我提供了 android sdk,所以我添加了一个频道并从颤振代码中调用 print。
【讨论】:
编辑:
你的情况,可以下载公司提供的SDK,编写原生代码打印收据。
示例:
在颤抖中
static const platform = const MethodChannel('com.example.myapplication');
Future<void> _print() async {
try {
final bool result = await platform.invokeMethod('print',{"data":Printdata});
if (result) {
// success
} else {
// failed
}
} on PlatformException catch (e) {
//failed to print
}
}
然后在 Main.java / Main.kt 中实现 SDK 文档中的方法
示例:
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
if (call.method.equals("print")) {
data = call.argument("data");
// Code from SDK documentation
} else {
result.notImplemented();
}
}
【讨论】:
试试这个库“flutter_bluetooth_serial”并通过直接mac地址连接到打印机,如下所示:
BluetoothConnection 连接 = 等待 BluetoothConnection.toAddress("mac");
【讨论】: