- 修改pubspec.yaml
# 蓝牙打印
blue_thermal_printer: ^1.2.3
- 修改\android\app\src\main\AndroidManifest.xml
<!-- 蓝牙打印权限 -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- 打印
import 'dart:convert';
import 'dart:typed_data';
import 'package:blue_thermal_printer/blue_thermal_printer.dart';
BlueThermalPrinter bluetooth = BlueThermalPrinter.instance;
BluetoothDevice _device;
void dioPrint() async {
List<BluetoothDevice> devices = await bluetooth.getBondedDevices();
if (devices.isEmpty) {
await YDialogs.showError('请先自行蓝牙配对XXXX打印机', context