Giter Club home page Giter Club logo

bluetooth_print's People

Contributors

imp-sike avatar thon-ju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bluetooth_print's Issues

xxx.a文件怎么引用到项目中

在项目中引入xxx.a文件需要配置什么,怎么配置?我这边引到项目,然后在xcode上点击run就提示是没找到xxx.a文件

功能建议:画线画框的方法

最近一直在关注这个项目,我也尝试用了一下,以后几点建议

  1. 缺少画线的方法
  2. 缺少画框的方法
  3. 最好能直接发送打印指令

谢谢

usb printer

how can i print to a printer on the usb port?

Additional characters are prefixed to String when printing Barcode

String text = "1234";

list.add(LineText(type: LineText.TYPE_BARCODE, content: text , size:10, align: LineText.ALIGN_CENTER, linefeed: 1));

Additional characters "{B" are prefixed to the barcode text after printing. Scanning the printed barcode still gives {B1234.

can't detect any bluetooth device

D/BluetoothPrintPlugin( 9980): start scan
D/BluetoothAdapter( 9980): STATE_ON
D/BluetoothLeScanner( 9980): onClientRegistered() - status=0 clientIf=6
I/flutter ( 9980): cur device status: 12
D/BluetoothAdapter( 9980): STATE_ON

repeating these lines while scanning

I can't print (Knup 1022)

Is something wrong with my code? I am trying to print using this function and an error is occurring, leave the logcat below.

void connectDevice(BuildContext context,
      {void Function(BluetoothPrint) connected}) {
    _bluetooth.state.listen((state) {
      if (state == BluetoothPrint.CONNECTED) {
        _bluetooth.printReceipt(Map(), [
          LineText(
              type: LineText.TYPE_TEXT,
              size: 12,
              content: 'Ola mundo',
              align: LineText.ALIGN_CENTER,
              linefeed: 1)
        ]);
      }
    });
    showDialog(
      context: context,
      barrierDismissible: false,
      builder: (_) {
        return AlertDialog(
          title: Text('Encontar dispositivos'),
          content: StreamBuilder<bool>(
            key: UniqueKey(),
            initialData: false,
            stream: _bluetooth.isScanning,
            builder: (_, status) {
              return Column(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  StreamBuilder<List<BluetoothDevice>>(
                    key: UniqueKey(),
                    initialData: [],
                    stream: _bluetooth.scanResults,
                    builder: (_, results) {
                      return results.data.length == 0 && status.data
                          ? Expanded(
                              child: Center(
                                child: CircularProgressIndicator(),
                              ),
                            )
                          : ListView(
                              key: UniqueKey(),
                              shrinkWrap: true,
                              children: results.data
                                  .map(
                                    (device) => ListTile(
                                      key: UniqueKey(),
                                      enabled: status.data ? false : true,
                                      title: Text('${device.name}'),
                                      subtitle: Text('${device.address}'),
                                      onTap: () {
                                        _bluetooth.connect(device);
                                      },
                                    ),
                                  )
                                  .toList(),
                            );
                    },
                  ),
                  FlatButton(
                    onPressed: () => status.data
                        ? _bluetooth.stopScan()
                        : _bluetooth.startScan(),
                    child: Text(status.data
                        ? 'ENCERRAR BUSCA'
                        : 'BUSCAR DISPOSITIOVOS'),
                  )
                ],
              );
            },
          ),
        );
      },
    );
  }
2020-01-17 16:54:30.657 24773-24925/juniojsv.bem_servir_comanda W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
2020-01-17 16:54:33.617 24773-24773/juniojsv.bem_servir_comanda D/BluetoothPrintPlugin: stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
2020-01-17 16:54:33.632 24773-24789/juniojsv.bem_servir_comanda E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(not connect, state not right, null)
    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
    #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
    <asynchronous suspension>
    #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
    #3      BluetoothPrint.printReceipt (package:bluetooth_print/bluetooth_print.dart:141:14)
    #4      AppModel.connectDevice.<anonymous closure> (package:bem_servir_comanda/models/app_model.dart:20:20)
    #5      _rootRunUnary (dart:async/zone.dart:1134:38)
    #6      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
    #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
    #8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
    #9      _DelayedData.perform (dart:async/stream_impl.dart:594:14)
    #10     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:710:11)
    #11     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:670:7)
    #12     _rootRun (dart:async/zone.dart:1122:38)
    #13     _CustomZone.run (dart:async/zone.dart:1023:19)
    #14     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
    #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
    #16     _rootRun (dart:async/zone.dart:1126:13)
    #17     _CustomZone.run (dart:async/zone.dart:1023:19)
    #18     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
    #19     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
    #20     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
    #21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
2020-01-17 16:54:33.820 24773-24960/juniojsv.bem_servir_comanda E/DeviceConnFactoryManager: wait read 
2020-01-17 16:54:35.573 24773-24960/juniojsv.bem_servir_comanda E/BluetoothPort: read length1
2020-01-17 16:54:35.573 24773-24960/juniojsv.bem_servir_comanda E/DeviceConnFactoryManager:  read 1
2020-01-17 16:54:35.575 24773-24960/juniojsv.bem_servir_comanda E/DeviceConnFactoryManager: wait read 

Image does not print in full

I have resized the image and changed the width. It still does not print Image in full.

list.add(
LineText(
width: 20,
type: LineText.TYPE_IMAGE,
content: base64Image,
align: LineText.ALIGN_CENTER,
linefeed: 1
)
);

update bluetooth_print to flutterEmbedding v2

i have been using this plugin for more than 6 month now without an issue but after adding new futures to my app like backgroundtask with workmanager and noftications with flutter_local_notfication will cause
Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@c154952) but could not find and invoke the GeneratedPluginRegistrant.
removing bluetooth_print from yaml file will make things works perfectly

C:\flutter\.pub-cache\hosted\pub.dartlang.org\bluetooth_print-2.0.0\android\src\main\java\com\example\bluetooth_print\BluetoothPrintPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

this plugin is the only one within the flutter community that serves my app needs (it can even be a paid task)

ios无法切纸的问题

我阅读了一下你的插件源码,发现在android的源码里面,PrintContent.java 中的mapToReceipt函数有以下实现,
//打印走纸n个单位
esc.addPrintAndFeedLines((byte) 4);

// 开钱箱
esc.addGeneratePlus(LabelCommand.FOOT.F2, (byte) 255, (byte) 255);
//开启切刀
esc.addCutPaper();
//添加缓冲区打印完成查询
byte [] bytes={0x1D,0x72,0x01};
//添加用户指令
esc.addUserCommand(bytes);

但是在ios里面,BluetoothPrintPlugin.m中的mapToEscCommand函数里,只有以下实现
[command addPrintAndFeedLines:4];
return [command getCommand];

是不是因为ios中没有实现开启切刀,所以才导致ios打印完小票后,无法切纸的问题呢?

Get connected devices

If phone is connecting a printer using other app or via phone bluetooth setting, we need show device is connected. I can't find a api, should be a feature request?

Scan not available

Hi Guys, i just download the package, but the method bluetoothPrint.startScan(timeout: Duration(seconds: 4)); it's not available.
How to proceed?

Scanning bluetooth devices give me empty list (Android 10).

I tried this package with 2 devices,

Device 1. I've tried scan bluetooth device in android 10 device (Redmi Note 9 : Bluetooth version is 5.0), but callback give me nothing.

Device 2. and then I've tried in android 9 device (Realme C2 : Bluetooth version is 4.2), while scanning for devices managed to get a list of devices including the printer. but I can't connect to the printer I want and terminal shows me like below :

D/BluetoothSocket(28482): close() this: android.bluetooth.BluetoothSocket@1a1c51a, channel: 2, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@80b084b, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@e3b9228mSocket: null, mSocketState: CLOSED
D/BluetoothSocket(28482): close() this: android.bluetooth.BluetoothSocket@1a1c51a, channel: 2, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@80b084b, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@e3b9228mSocket: null, mSocketState: CLOSED
W/System.err(28482): java.io.IOException: bt socket closed, read return: -1
W/System.err(28482): 	at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:558)
W/System.err(28482): 	at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)
W/System.err(28482): 	at java.io.InputStream.read(InputStream.java:101)
W/System.err(28482): 	at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130)
W/System.err(28482): 	at com.example.bluetooth_print.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:416)
W/System.err(28482): 	at com.example.bluetooth_print.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:496)
E/BluetoothPort(28482): connection device is lost
E/DeviceConnFactoryManager(28482):  read 0
D/BluetoothPrintPlugin(28482): stateStreamHandler, current action: android.bluetooth.device.action.ACL_DISCONNECTED
I/flutter (28482): cur device status: 0

*Printer
XPrinter BP-428U

ios打印完小票无法自动切纸

我基于flutter:1.22.4 ,bluetooth_print:2.0.0,做蓝牙打印机测试,在ios端,打印完小票之后,打印机无法自动切纸,android端可以正常切纸。测试过2款打印机,都有这个问题,机器分别是,GP-L80160I,BTP-X66
另外,华为P30 pro上面运行的时候,无法搜索到蓝牙打印机设备。

LICENSE

What is the license for this library? can i suggest MIT?

BluetoothPort connection device is lost

Ho To Fix This Error
E/BluetoothPort(29198): connection device is lost
E/DeviceConnFactoryManager(29198): read 0
D/BluetoothPrintPlugin(29198): stateStreamHandler, current action: android.bluetooth.device.action.ACL_DISCONNECTED

打印二维码不能设置大小

config['width'] = 40; // 标签宽度,单位mm
config['height'] = 70; // 标签高度,单位mm
config['gap'] = 2; // 标签间隔,单位mm
// x、y坐标位置,单位dpi,1mm=8dpi
List<LineText> list = List();
list.add(
    LineText(type: LineText.TYPE_TEXT, x: 10, y: 10, content: 'A Title'));
list.add(LineText(
    type: LineText.TYPE_TEXT, x: 10, y: 40, content: 'this is content'));
list.add(LineText(
    type: LineText.TYPE_QRCODE, x: 10, y: 70,size: 240, content: 'qrcode i\n'));
list.add(LineText(
    type: LineText.TYPE_BARCODE, x: 10, y: 190, content: 'qrcode i\n'));

await bluetoothPrint.printLabel(config, list);

can not build example

Hello,

I can not build your example,

I got this error:

C:\Users\bekir.oruc\AndroidStudioProjects\nuqud_mobile\android\app\src\debug\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:bluetooth_print] C:\Users\bekir.oruc\AndroidStudioProjects\nuqud_mobile\build\bluetooth_print\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.example.bluetooth_print" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:bluetooth_print] C:\Users\bekir.oruc\AndroidStudioProjects\nuqud_mobile\build\bluetooth_print\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.example.bluetooth_print" to force usage (may lead to runtime failures)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

How to save _device instance for relaunch

Hello, Thank you for bluetooth_print plugin, I am interested and testing the plugin in Android and iOS, mean while I am realizing that we need to select the device on every launch of application, to avoid this, how to save _device instance for ever until disconnect the device.

Thanks.

QR Code prints as normal text

Hi,
Have you checked the QR Code printing? I tried to pass a set of string to print as QR Code, but it prints as normal text instead QRCode.

Please help me on this.

Thanks
Elango.

汉印便携式打印机根本不能使用

复现步骤:

    1. 下载此GitHub项目到电脑上
    1. 运行项目到Android手机上,使用此app连接蓝牙打印设备:“无法与‘xxx’进行配对”
    1. 运行项目到iOS手机上,使用此app连接蓝牙打印设备,成功地连接;使用此app进行打印数据,打印出的效果不能使用:出现了火星文-->如下图所示

499D888FEBC0A887C1D5253B17AC0138

急急急!

It does not detect devices

It detects me if there is a device connected but it does not load the information of the devices. scanResults is empty.

Can not get the plugin work on android sdk 29

here is my build.gradle file
` compileSdkVersion 29

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.com"
    minSdkVersion 22
    targetSdkVersion 29
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}`

And When I try to print I get this error Attempt to invoke virtual method 'com.example.bluetooth_print.PrinterCommand com.example.bluetooth_print.DeviceConnFactoryManager.getCurrentPrinterCommand()' on a null object reference E/AndroidRuntime(32188): at com.example.bluetooth_print.BluetoothPrintPlugin$5.run(BluetoothPrintPlugin.java:326) E/AndroidRuntime(32188): at com.example.bluetooth_print.ThreadPool$1.run(ThreadPool.java:78) E/AndroidRuntime(32188): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/AndroidRuntime(32188): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/AndroidRuntime(32188): at java.lang.Thread.run(Thread.java:919) I/Process (32188): Sending signal. PID: 32188 SIG: 9

Note on android sdk 28 works as expected.

打印BARCODE类型设置content内容失效 一直打印SMARNET

我查看你的源代码发现 这行代码if("barcode".equals(type)){
tsc.add1DBarcode(x, y, LabelCommand.BARCODETYPE.CODE128, 100, LabelCommand.READABEL.EANBEL, LabelCommand.ROTATION.ROTATION_0,"SMARNET");
}
SMARNET已被写死 我该如何给BARCODE类型设置内容呢?

Accents not working

Hello,

we cannot print accents and this is a huge problem.

Mère et Père do not print, they show up as:

M??re P??re

(the ? are upside down however)

app crashes after start searching for bluetooth devices (ios)

the app working fine on android but when i tested with ios it crashed the sec i start searching ...

xcode output :

2020-03-04 17:44:40.310095+0100 Runner[94466:2281835] call method -> startScan
2020-03-04 17:44:40.310386+0100 Runner[94466:2281835] getDevices method -> startScan
2020-03-04 17:44:40.312031+0100 Runner[94466:2281835] *** Assertion failure in -[CBCentralManager initWithDelegate:queue:options:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/MobileBluetoothFramework_Sim/MobileBluetooth-132.8/CoreBluetooth/CoreBluetooth/CBCentralManager.m:230
2020-03-04 17:44:40.326653+0100 Runner[94466:2281835] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'State restoration of CBCentralManager is only allowed for applications that have specified the "bluetooth-central" background mode'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000011345d27e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x0000000113251b20 objc_exception_throw + 48
	2   CoreFoundation                      0x000000011345cff8 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x0000000112c79b51 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   CoreBluetooth                       0x00000001132ae101 -[CBCentralManager initWithDelegate:queue:options:] + 910
	5   Runner                              0x000000010f47ef0a -[BLEConnecter initParament] + 292
	6   Runner                              0x000000010f47eddc -[BLEConnecter init] + 66
	7   Runner                              0x000000010f48a85d -[ConnecterManager initConnecter:] + 61
	8   Runner                              0x000000010f48a7ee -[ConnecterManager didUpdateState:] + 94
	9   Runner                              0x000000010f486aae -[BluetoothPrintPlugin handleMethodCall:result:] + 1486
	10  Flutter                             0x00000001101ecdb5 Flutter + 581045
	11  Flutter                             0x0000000110180ba0 Flutter + 138144
	12  Flutter                             0x000000011018464e Flutter + 153166
	13  Flutter                             0x00000001101e6969 Flutter + 555369
	14  Flutter                             0x0000000110193b73 Flutter + 215923
	15  Flutter                             0x00000001101988b8 Flutter + 235704
	16  CoreFoundation                      0x00000001133c0b94 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
	17  CoreFoundation                      0x00000001133c0882 __CFRunLoopDoTimer + 1026
	18  CoreFoundation                      0x00000001133bfeda __CFRunLoopDoTimers + 266
	19  CoreFoundation                      0x00000001133bac4e __CFRunLoopRun + 2238
	20  CoreFoundation                      0x00000001133ba066 CFRunLoopRunSpecific + 438
	21  GraphicsServices                    0x0000000116a22bb0 GSEventRunModal + 65
	22  UIKitCore                           0x000000011d667d4d UIApplicationMain + 1621
	23  Runner                              0x000000010f47df50 main + 112
	24  libdyld.dylib                       0x00000001141bcc25 start + 1
	25  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Upgrade the package

hello,

i am getting this error and it's urgent we fix this bug please

Because build_runner >=2.0.0 depends on timing ^1.0.0 which depends on json_annotation ^4.0.0, build_runner >=2.0.0 requires json_annotation ^4.0.0.

And because bluetooth_print 2.0.0 depends on json_annotation ^3.0.1, build_runner >=2.0.0 is incompatible with bluetooth_print 2.0.0.

So, because cg_passport_management_interface depends on both bluetooth_print 2.0.0 and build_runner 2.0.2, version solving failed.
pub get failed (1; So, because cg_passport_management_interface depends on both bluetooth_print 2.0.0 and build_runner 2.0.2, version solving failed.)
exit code 1

搜索不到打印机设备

测试打印机是:
品牌:epson
型号:LW-600P
测试的时候发现搜索不到设备。
手机蓝牙功能是开启的,在蓝牙设置里面能扫描到设备

打印安卓二维码浓度低,无法使用和连接异常和断开连接异常的问题

我的蓝牙打印机在打印QRCODE(二维码)中安卓打印的清晰度太低,导致无法正常使用,后来在printContext中把打印浓度的枚举类从7(好像是7)改成了15,之后可以安卓打印二维码就可以非常清晰了。但是现在存在以下问题:
1:无法判断当前蓝牙设备是否已经正常连接,判断结果往往是错的bluetoothPrint.isConnected和bluetoothPrint.state.listen监听的结果汪汪是错的。
2:bluetoothPrint.connect(device)方法中,往往device不是null反而会出现NullException。
3:bluetoothPrint.disconnect()这个方法经常使用时会导致应用直接崩溃掉(闪退)
`import 'package:bluetooth_print/bluetooth_print.dart';
import 'package:bluetooth_print/bluetooth_print_model.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:guards/bean/BlueJurisdiction.dart';
import 'package:guards/utils/interface/BluetoothFactory.dart';

/// @description BluetoothFactoryImpl
/// @author Activation
/// @Date 2021/1/26 11:14
class BluetoothFactoryImpl implements BluetoothFactory {
BluetoothPrint bluetoothPrint = BluetoothPrint.instance;
bool isConnFlag = false;

@OverRide
Future disconnect() async {
await bluetoothPrint.stopScan();
await bluetoothPrint.disconnect();
await bluetoothPrint.destroy();
}

@OverRide
Future checkBluetoothAccess() async {
bool openFlag = await bluetoothPrint.isOn;

if (!openFlag) {
  //DialogUtil().showMsg(context, "请您先开启蓝牙");
  return BlueJurisdiction(false, "请您先开启蓝牙");
}
bool authorityFlag = await bluetoothPrint.isAvailable;
if (!authorityFlag) {
  //DialogUtil().showMsg(context, "请您先授予蓝牙的使用权限");
  return BlueJurisdiction(false, "请您先授予蓝牙的使用权限");
}
return BlueJurisdiction(true, "可以连接蓝牙");
//bluetoothPrint.isConnected.then((value) => print(value));

}

@OverRide
Future joinBluetooth() async {
EasyLoading.show(status: "连接蓝牙中。。");
try {
await bluetoothPrint.startScan(timeout: Duration(seconds: 4));
Stream<List> tempStream = bluetoothPrint.scanResults;
print(tempStream);
bool tempFlag = false;
//执行自动连接
tempStream.listen((event) async {
for (BluetoothDevice device in event) {
if (device.name.startsWith(r"Printer_")) {
tempFlag = true;
if (tempFlag && device != null) {
// await bluetoothPrint.disconnect();
print("这里是连接的设备信息$device");
await bluetoothPrint.connect(device);
await bluetoothPrint.stopScan();
}
}
}
});
await bluetoothPrint.isConnected.then((value) {
print("这里是对应的当前值是否已经连接的返回值$value");
});
bluetoothPrint.state.listen((state) {
print("这里是正在监听值的变化$state");
switch (state) {
case BluetoothPrint.CONNECTED:
print("蓝牙已经连接了");
isConnFlag = true;
break;
case BluetoothPrint.DISCONNECTED:
isConnFlag = false;
print("蓝牙还没有连接");
break;
default:
break;
}
});
} catch (e) {
print("这里是对应的异常信息");
print("${e.runtimeType}${e.toString()}");
} finally {
EasyLoading.dismiss();
}
}

@OverRide
Future executePrint(List tempLists) async {
print("这里已经执行了$isConnFlag");
if (isConnFlag) {
await bluetoothPrint.printLabel(config, tempLists);
} else {
throw Exception("当前设备未连接,请关闭蓝牙之后再重试");
// await joinBluetooth().then((value) {
// bluetoothPrint.printLabel(config, tempLists);
// });
}
}

@OverRide
Map<String, dynamic> config = {'width': 300, 'height': 220, 'gap': 30};
}
`
然后我希望您能联系我,我可以协助您完善这个组件,因为我也需要使用这个组件,并且希望他可以成熟。
我的打印机型号为:GP-M322
我的QQ:1067252205
还有楼主的群号重新发下吧。。。。。 我也想进群交流讨论

QR Code doesn`t work, Accent (latin characters) doesn`t work

Print as empty space. Testing with the example provided.

Model: amazon link
Specifications:
Model: POS-5802DD
Printing Method: Direct Thermal
Speed: =<90mm/sec
Resolution: 203dpi(8dot/mm)
Paper Type: Thermal Paper
Paper Width: 58mm(+-0.1mm)
Printing Width: 40mm(384dot)
Roll Diameter: =<40mm
Reliability TPH Life: 100km
BT Version: 4.0 & 3.0
Character size: 384dots/line
Font A: 12 * 24dots, 1.5(W) * 3.0(H)mm
Font B: 9 17dots, 1.1(W) 2.1(H)mm
Simplified/Traditional: 24 * 24dots, 3.0(W)*3.0(H)
Extended Character: OEM437/Katakana/OEM850/OEM860/OEM863/OEM865/West Europe/Greek/Hebrew/East Europe/Iran/WPC1252/OEM866/OEM852/OEM858/Iran II/Latvian/Arabic/PT151,1251/OEM747/WPC1257/Vietnam/OEM864/Hebrew/WPC1255/Thai
Print Parameters: Support to download trademark, support bar-code print.
Support Bar Code Type: UPC-A/UPC-E/JAN13(EAN13)/JAN8(EAN8)/CODE39/ITF/CODABAR/CODE93/CODE128;Two-Dimensional Cord: QR Code
Emulation: ESC/POS/STAR Command
Interface: USB/Serial/Power Port
Driver: For Win2003/Win2000/Win7/Win XP/VISTA/Win8/Win10/LINUX
Battery: 7.4V 1500mAh 11.1Wh (Included)
AC Input: 100 ~ 240V 50/60Hz 0.5A max.
Output: DC 9V/1.5A

Font Size

Hi, I've tried a lot of command to increase text, including weight and size when I create LineText, I don't know if there are other commands to increase this, but I don't found it and if you can include this possibility in your code would be great. (I test only in esc mode)

Control size of image

hello, I have try with size paper 58mm, and try to control size of image, how to do that

/android/app/src/debug/AndroidManifest.xml Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 18 declared in library [:bluetooth_print]

**> /android/app/src/debug/AndroidManifest.xml Error:

    uses-sdk:minSdkVersion 16 cannot be smaller than version 18 declared in library [:bluetooth_print]**

I stuck on this error in 2 days. I found the solution to this issue.

Open printer_app/android/build.gradle:
Change the following line as lower version.

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 16  // Before it was 18
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}

However, I found the solution. I don't understand minSdk problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.