Coder Social home page Coder Social logo

andrey-ushakov / esc_pos_bluetooth Goto Github PK

View Code? Open in Web Editor NEW
235.0 15.0 305.0 104 KB

ESC/POS (thermal, receipt) printing for Flutter & Dart (Android/iOS)

License: BSD 3-Clause "New" or "Revised" License

Dart 80.63% Kotlin 1.69% Ruby 14.56% Objective-C 3.12%
dart flutter bluetooth-printer pos receipt thermal-printer receipt-printer esc

esc_pos_bluetooth's Introduction

esc_pos_bluetooth

Pub Version

The library allows to print receipts using a Bluetooth printer. For WiFi/Ethernet printers, use esc_pos_printer library.

TODO (PRs are welcomed!)

  • Split byte data into chunks: issue
  • Print QR Codes using the GS ( k command (printing QR code from an image already supported)
  • PDF-417 Barcodes using the GS ( k command
  • Line spacing using the ESC 3 <n> command

How to Help

  • Test your printer and add it in the table: Wifi/Network printer or Bluetooth printer
  • Test and report bugs
  • Share your ideas about what could be improved (code optimization, new features...)
  • PRs are welcomed!

Tested Printers

Here are some printers tested with this library. Please add the models you have tested to maintain and improve this library and help others to choose the right printer.

Generate a Ticket

Simple Ticket with Styles:

Ticket testTicket() {
  final Ticket ticket = Ticket(PaperSize.mm80);

  ticket.text(
      'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
  ticket.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
      styles: PosStyles(codeTable: PosCodeTable.westEur));
  ticket.text('Special 2: blåbærgrød',
      styles: PosStyles(codeTable: PosCodeTable.westEur));

  ticket.text('Bold text', styles: PosStyles(bold: true));
  ticket.text('Reverse text', styles: PosStyles(reverse: true));
  ticket.text('Underlined text',
      styles: PosStyles(underline: true), linesAfter: 1);
  ticket.text('Align left', styles: PosStyles(align: PosAlign.left));
  ticket.text('Align center', styles: PosStyles(align: PosAlign.center));
  ticket.text('Align right',
      styles: PosStyles(align: PosAlign.right), linesAfter: 1);

  ticket.text('Text size 200%',
      styles: PosStyles(
        height: PosTextSize.size2,
        width: PosTextSize.size2,
      ));

  ticket.feed(2);
  ticket.cut();
  return ticket;
}

You can find more examples here: esc_pos_utils.

Print a Ticket

PrinterBluetoothManager printerManager = PrinterBluetoothManager();

printerManager.scanResults.listen((printers) async {
  // store found printers
});
printerManager.startScan(Duration(seconds: 4));

// ...

printerManager.selectPrinter(printer);
final PosPrintResult res = await printerManager.printTicket(testTicket());

print('Print result: ${res.msg}');

For a complete example, check the demo project example/blue.

Troubleshooting

  • If your printer prints only 5%-10% of an image and then stops, or it can't print more than 1 image on the same ticket, or it can't print long tickets, try to ajust queueSleepTimeMs of the PrinterBluetoothManager.printTicket (try 50 or 100ms): printerManager.printTicket(await demoReceipt(paper), queueSleepTimeMs: 50);

Test Print

test receipt

test receipt

esc_pos_bluetooth's People

Contributors

andrey-ushakov avatar kivanccakmak avatar youcef-goudjal 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  avatar  avatar  avatar

esc_pos_bluetooth's Issues

devices list is empty

I'm testing to see if the plugin can detect nearby Bluetooth devices but the device list is empty

unable to discover divices when using skd version 29

Hello everyone,
The package seems to not work when using targetSdkVersion 29 in android. I have not tried it in ios. My project is using sdk29.

To reproduce, change

defaultConfig { applicationId "com.example.blue" minSdkVersion 21 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }

to

defaultConfig { applicationId "com.example.blue" minSdkVersion 21 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }

I added the following permission and it is still not working:
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

I need your help solving this problem.

It does not find my printer

It does not find my printer, bixolon SPP-310, and it is already paired on my phone, the only thing it found was my smartwatch, it should scan any bluetooth device

Prints only once when the app starts

I can only be able to print once, only when the app starts for the first time, subsequent attempts to print am getting Printer connection timeout
Here are the logs.

D/BluetoothBasicPlugin(31167): start scan 
D/BluetoothAdapter(31167): STATE_ON
I/chatty  (31167): uid=10277(ke.co.quebasetech.wanga_admin) identical 1 line
D/BluetoothAdapter(31167): STATE_ON
D/BluetoothLeScanner(31167): Start Scan with callback
D/BluetoothLeScanner(31167): onScannerRegistered() - status=0 scannerId=9 mScannerId=0
D/BluetoothAdapter(31167): STATE_ON
D/BluetoothAdapter(31167): STATE_ON
D/BluetoothLeScanner(31167): Stop Scan with callback
D/BluetoothAdapter(31167): STATE_ON
D/BluetoothAdapter(31167): STATE_ON
D/BluetoothLeScanner(31167): could not find callback wrapper
D/BluetoothSocket(31167): close() this: android.bluetooth.BluetoothSocket@2173db5, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@7b09c4a, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@10d47bbmSocket: android.net.LocalSocket@424b4d8 impl:android.net.LocalSocketImpl@9cb0031 fd:java.io.FileDescriptor@c643316, mSocketState: CONNECTED
W/System.err(31167): java.io.IOException: bt socket closed, read return: -1
D/BluetoothSocket(31167): close() this: android.bluetooth.BluetoothSocket@2173db5, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@7b09c4a, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@10d47bbmSocket: null, mSocketState: CLOSED
D/BluetoothSocket(31167): close() this: android.bluetooth.BluetoothSocket@2173db5, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@7b09c4a, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@10d47bbmSocket: null, mSocketState: CLOSED
W/System.err(31167): 	at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:721)
W/System.err(31167): 	at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)
W/System.err(31167): 	at java.io.InputStream.read(InputStream.java:101)
W/System.err(31167): 	at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130)
W/System.err(31167): 	at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:418)
W/System.err(31167): 	at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:498)
E/BluetoothPort(31167): connection device is lost
E/DeviceConnFactoryManager(31167):  read 0
D/BluetoothAdapter(31167): cancelDiscovery
D/BluetoothAdapter(31167): cancelDiscovery = true
D/BluetoothUtils(31167): isSocketAllowedBySecurityPolicy start : device null
W/BluetoothAdapter(31167): getBluetoothService() called with no BluetoothManagerCallback
E/DeviceConnFactoryManager(31167): wait read 
E/BluetoothPort(31167): read length1
E/DeviceConnFactoryManager(31167):  read 1
E/DeviceConnFactoryManager(31167): wait read 
I/flutter (31167): Error. Printer connection timeout

Can't find Ticket class

Compiler message:
lib/main.dart:26:17: Error: 'Ticket' isn't a type.
Ticket ticket = Ticket(PaperSize.mm80);
^^^^^^
lib/main.dart:26:33: Error: The method 'Ticket' isn't defined for the class '_MyAppState'.

  • '_MyAppState' is from 'package:test_printer/main.dart' ('lib/main.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'Ticket'.
    Ticket ticket = Ticket(PaperSize.mm80);
    ^^^^^^
    lib/main.dart:26:40: Error: The getter 'PaperSize' isn't defined for the class '_MyAppState'.
  • '_MyAppState' is from 'package:test_printer/main.dart' ('lib/main.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'PaperSize'.
    Ticket ticket = Ticket(PaperSize.mm80);

W/System.err(10182): java.io.IOException: bt socket closed, read return: -1

Hi Andrey,

I am getting the following error. Please help.

/BluetoothBasicPlugin(10182): start scan
D/BluetoothAdapter(10182): isLeEnabled(): ON
D/BluetoothLeScanner(10182): onScannerRegistered() - status=0 scannerId=7 mScannerId=0
D/BluetoothAdapter(10182): isLeEnabled(): ON
D/BluetoothAdapter(10182): isLeEnabled(): ON
D/BluetoothLeScanner(10182): could not find callback wrapper
W/BluetoothAdapter(10182): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothBasicPlugin(10182): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
E/DeviceConnFactoryManager(10182): wait read
E/BluetoothPort(10182): read length1
E/DeviceConnFactoryManager(10182): read 1
E/DeviceConnFactoryManager(10182): wait read
W/System.err(10182): java.io.IOException: bt socket closed, read return: -1
W/System.err(10182): at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:558)
W/System.err(10182): at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)

Print long arabic Text

greeting iam using zebra zq320 i managed to print arabic text but he problem is the text was too long there will be a problem that not all the text is printed i tried to split the next to several part for example the code blew i tried to send it 3 times first 2 will print correct third will print maybe 1 or 2 lines from it
iam using zpl lang
i tried even to change the
chunkSizeBytes,queueSleepTimeMs
but no hope can anyone suggest

        zplData="";
 zplData = zplData + " ^XA^CWZ,E:TT0003M_.FNT^FS";
 			 
				zplData = zplData + "^MNN^LL800";

for(int i=10;i<20;i++)
{
 	zplData = zplData + " ^FO05," + start.toString() + "^CI28^AZN,30,30^FD  "+i.toString()+" ^FS";
				zplData = zplData + " ^FO140," + start.toString() + "^CI28^AZN,30,30^FD 20" + " ^FS";
					zplData = zplData + " ^FO230," + start.toString() + "^CI28^AZN,30,30^FD 500" + " ^FS";
				zplData = zplData + " ^FO385," + start.toString() + "^CI28^AZN,30,30^FD حليب تنوفا 2 لتر" + " ^FS";
				start = start + lineSpace;
}
      
				zplData = zplData + " ^FO05," + start.toString() + "^CI28^AZN,30,30^FD ______________________________________" + " ^FS";
				
  				zplData = zplData + " ^XZ";
        
    Uint8List encArabic1 = await CharsetConverter.encode("UTF-8",zplData);
ticket.textEncoded(encArabic1,
    styles: PosStyles(codeTable: PosCodeTable.arabic));
 

getBluetoothService() called with no BluetoothManagerCallback

I'm running the example project "Blue" and I'm getting this error:

/BluetoothBasicPlugin(31020): start scan 
D/BluetoothAdapter(31020): isLeEnabled(): ON
D/BluetoothLeScanner(31020): onScannerRegistered() - status=0 scannerId=9 mScannerId=0
D/BluetoothAdapter(31020): isLeEnabled(): ON
D/BluetoothBasicPlugin(31020): start scan 
D/BluetoothAdapter(31020): isLeEnabled(): ON
D/BluetoothLeScanner(31020): onScannerRegistered() - status=0 scannerId=9 mScannerId=0
D/BluetoothAdapter(31020): isLeEnabled(): ON
D/BluetoothAdapter(31020): isLeEnabled(): ON
D/BluetoothLeScanner(31020): could not find callback wrapper
W/BluetoothAdapter(31020): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothBasicPlugin(31020): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
E/DeviceConnFactoryManager(31020): wait read 
E/flutter (31020): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: Future already completed
E/flutter (31020): #0      _AsyncCompleter.complete (dart:async/future_impl.dart:41:31)
E/flutter (31020): andrey-ushakov/esc_pos_printer#1      PrinterBluetoothManager.writeBytes.<anonymous closure> (package:esc_pos_printer/src/printer_bluetooth_manager.dart:121:19)
E/flutter (31020): andrey-ushakov/esc_pos_printer#2      _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (31020): andrey-ushakov/esc_pos_printer#3      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (31020): andrey-ushakov/esc_pos_printer#4      _FutureListener.handleValue (dart:async/future_impl.dart:140:18)
E/flutter (31020): andrey-ushakov/esc_pos_printer#5      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
E/flutter (31020): andrey-ushakov/esc_pos_printer#6      Future._propagateToListeners (dart:async/future_impl.dart:711:32)
E/flutter (31020): andrey-ushakov/esc_pos_printer#7      Future._complete (dart:async/future_impl.dart:516:7)
E/flutter (31020): andrey-ushakov/esc_pos_printer#8      new Future.delayed.<anonymous closure> (dart:async/future.dart:313:16)
E/flutter (31020): andrey-ushakov/esc_pos_printer#9      _rootRun (dart:async/zone.dart:1122:38)
E/flutter (31020): andrey-ushakov/esc_pos_printer#10     _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (31020): andrey-ushakov/esc_pos_printer#11     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (31020): andrey-ushakov/esc_pos_printer#12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter (31020): andrey-ushakov/esc_pos_printer#13     _rootRun (dart:async/zone.dart:1126:13)
E/flutter (31020): andrey-ushakov/esc_pos_printer#14     _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (31020): andrey-ushakov/esc_pos_printer#15     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
E/flutter (31020): andrey-ushakov/esc_pos_printer#16     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
E/flutter (31020): andrey-ushakov/esc_pos_printer#17     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (31020): andrey-ushakov/esc_pos_printer#18     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (31020): andrey-ushakov/esc_pos_printer#19     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (31020): 
D/BluetoothSocket(31020): close() this: android.bluetooth.BluetoothSocket@a214a42, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@5d8ea53, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@3f33f90mSocket: android.net.LocalSocket@5502089 impl:android.net.LocalSocketImpl@ffdc88e fd:java.io.FileDescriptor@dfdd8af, mSocketState: CONNECTED
D/BluetoothSocket(31020): close() this: android.bluetooth.BluetoothSocket@a214a42, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@5d8ea53, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@3f33f90mSocket: null, mSocketState: CLOSED
W/System.err(31020): java.io.IOException: bt socket closed, read return: -1
D/BluetoothSocket(31020): close() this: android.bluetooth.BluetoothSocket@a214a42, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@5d8ea53, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@3f33f90mSocket: null, mSocketState: CLOSED
W/System.err(31020):    at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:564)
W/System.err(31020):    at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)
W/System.err(31020):    at java.io.InputStream.read(InputStream.java:101)
W/System.err(31020):    at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130)
W/System.err(31020):    at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:418)
W/System.err(31020):    at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:498)
E/BluetoothPort(31020): connection device is lost
E/DeviceConnFactoryManager(31020):  read 0
D/BluetoothBasicPlugin(31020): stateStreamHandler, current action: android.bluetooth.device.action.ACL_DISCONNECTED

I'm using flutter 1.14.6

Flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.14.6, on Mac OS X 10.15.3 19D76, locale es-419)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.42.1)
[✓] Connected device (3 available)

• No issues found!

bounded device

i have problem to find device.

i think this library must show all bounded devices to connect instead of scan

is possible add this method to this library ?
thanks

using esc_pos_bluetooth and esc_pos_printer in 1 project

Getting error:
Because no versions of esc_pos_printer match >4.0.3 <5.0.0 and esc_pos_printer 4.0.3 depends on esc_pos_utils ^1.0.0, esc_pos_printer ^4.0.3 requires esc_pos_utils ^1.0.0.
And because esc_pos_bluetooth >=0.2.8 depends on esc_pos_utils ^0.3.6, esc_pos_printer ^4.0.3 is incompatible with esc_pos_bluetooth >=0.2.8.
So, because ticket_scan depends on both esc_pos_bluetooth ^0.2.8 and esc_pos_printer ^4.0.3, version solving failed.
pub get failed (1; So, because tibox depends on both esc_pos_bluetooth ^0.2.8 and esc_pos_printer ^4.0.3, version solving failed.)

could not find callback wrapper

i have try to change value queueSleepTimeMs in this line

Future printTicket(
Ticket ticket, {
int chunkSizeBytes = 50,
int queueSleepTimeMs = 100,
}) async {

can connect device only 1 second .. and then connection lost ...
my printer is NYEAR

Performing hot reload...
Reloaded 4 of 1325 libraries in 1,653ms.
D/BluetoothBasicPlugin(10907): start scan
D/BluetoothAdapter(10907): isLeEnabled(): ON
D/BluetoothLeScanner(10907): onScannerRegistered() - status=0 scannerId=8 mScannerId=0
E/flutter (10907): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (10907): #0 Iterable.first (dart:core/iterable.dart:520:7)
E/flutter (10907): #1 showToast (package:oktoast/src/core/toast.dart:45:34)
E/flutter (10907): #2 BasicLayout16State._testPrint (package:erp/basic_material_design/basic_layout_16.dart:288:5)
E/flutter (10907):
E/flutter (10907): #3 BasicLayout16State.build.. (package:erp/basic_material_design/basic_layout_16.dart:302:28)
E/flutter (10907): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (10907): #5 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (10907): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (10907): #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (10907): #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (10907): #9 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter (10907): #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (10907): #11 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (10907): #12 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (10907): #13 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (10907): #14 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (10907): #15 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (10907): #16 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (10907): #17 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (10907): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (10907): #19 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (10907): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter (10907):
D/BluetoothAdapter(10907): isLeEnabled(): ON
D/BluetoothBasicPlugin(10907): start scan
D/BluetoothAdapter(10907): isLeEnabled(): ON
D/BluetoothLeScanner(10907): onScannerRegistered() - status=0 scannerId=8 mScannerId=0
D/BluetoothAdapter(10907): isLeEnabled(): ON
D/BluetoothAdapter(10907): isLeEnabled(): ON
D/BluetoothLeScanner(10907): could not find callback wrapper
W/BluetoothAdapter(10907): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothBasicPlugin(10907): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
E/DeviceConnFactoryManager(10907): wait read
E/flutter (10907): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (10907): #0 Iterable.first (dart:core/iterable.dart:520:7)
E/flutter (10907): #1 showToast (package:oktoast/src/core/toast.dart:45:34)
E/flutter (10907): #2 BasicLayout16State._testPrint (package:erp/basic_material_design/basic_layout_16.dart:288:5)
E/flutter (10907):
E/flutter (10907): #3 BasicLayout16State.build.. (package:erp/basic_material_design/basic_layout_16.dart:302:28)
E/flutter (10907): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (10907): #5 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (10907): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (10907): #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (10907): #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (10907): #9 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter (10907): #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (10907): #11 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (10907): #12 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (10907): #13 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (10907): #14 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (10907): #15 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (10907): #16 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (10907): #17 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (10907): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (10907): #19 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (10907): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter (10907):
D/BluetoothSocket(10907): close() this: android.bluetooth.BluetoothSocket@917d849, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@483854e, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@6f1b66fmSocket: android.net.LocalSocket@35aaf7c impl:android.net.LocalSocketImpl@4fcb005 fd:java.io.FileDescriptor@616a85a, mSocketState: CONNECTED
D/BluetoothSocket(10907): close() this: android.bluetooth.BluetoothSocket@917d849, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@483854e, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@6f1b66fmSocket: null, mSocketState: CLOSED
D/BluetoothSocket(10907): close() this: android.bluetooth.BluetoothSocket@917d849, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@483854e, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@6f1b66fmSocket: null, mSocketState: CLOSED
W/System.err(10907): java.io.IOException: bt socket closed, read return: -1
W/System.err(10907): at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:523)
W/System.err(10907): at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:96)
W/System.err(10907): at java.io.InputStream.read(InputStream.java:101)
W/System.err(10907): at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130)
W/System.err(10907): at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:418)
W/System.err(10907): at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:498)
E/BluetoothPort(10907): connection device is lost
E/DeviceConnFactoryManager(10907): read 0
D/BluetoothBasicPlugin(10907): stateStreamHandler, current action: android.bluetooth.device.action.ACL_DISCONNECTED

rebase on flutter_blue?

Hi,

Great package but I miss a few things like being able to access advertisement data of the bluetooth devices to filter out printers only?

Would it be an idea to re-base this on https://pub.dev/packages/flutter_blue which seems to be a bit more mature than flutter_bluetooth_basic?

The functionality is pretty much the same.

Need to print larger than size8 Text with new printer NCTS-RBP4

I simply need to print a much larger number, using the embedded sizes in your package (size1 to size8), I probably need a size32. I need it to be 3X or 4X size 8.
How can I achieve that plz?

I'm successfully connecting + printing with a Bluetooth Thermal printer model: NCTS-RBP4

Facing issue problem though: getBluetoothService() called with no BluetoothManagerCallback

Printer itself does not cut, did not yet tried printing Barcodes/Images etc etc or done any intensive testing.

Cyrillic symbols

Hello, thank for your plugin!

How to add cyrillic symbols for printing?

Ticket.row PosColumn Alignment is indented

Hello, I try to use print on Bluetooth thermal printer from iOS.

the column seems to be indented and takes 2 lines.

I'm using eppos thermal printer using 58mm paper

my code (result with a red circle):


for (var i = widget.data.length - 1; i >= 0; i--) {
      ticket.row([
        PosColumn(
          text: widget.data[i].qty.toString(), //+ ' ' + widget.data[i].productName,
          width: 2,
          // styles: PosStyles(align: PosAlign.left),
        ),
        PosColumn(
          text: widget.data[i].productName,
          width: 4,
          styles: PosStyles(align: PosAlign.left),
        ),
        PosColumn(
          text: numSeparator(widget.data[i].subTotal),
          width: 4,
          styles: PosStyles(align: PosAlign.right),
        ),
        PosColumn(
          text: '',
          width: 2,
          styles: PosStyles(align: PosAlign.right),
        ),
      ]);
    }

Screen Shot 2020-11-24 at 15 25 09

print from example:
Screen Shot 2020-11-24 at 15 29 28

Non BLE printer

I have a non ble device.
Android works fine. But ios doesnt.
From my understanding non ble devices dont work with CoreBluetooth Api and need to use ExternalAccessory Api.
Is there a chance that you support non ble devices?

Print on sunmi t2 (InnerPrinter) problem

Hi,

Thanks for your package. I use a Sunmi T2 Terminal with a virtual bluethooth (INNERPRINTER).
When I print a ticket, a 'V0' caracter is write at each lines. Another problem when the ticket is finished, the printer cut 2 times at the end.

Thanks for your help
20200930_092817

Print 2 QRCode

write code to print only one qrcode but the result printed 2 qrcode.

Only prints the last column in a row

Tested with the example app, for e.g line:

    ticket.row([
      PosColumn(text: '2', width: 1),
      PosColumn(text: 'ONION RINGS', width: 7),
      PosColumn(
          text: '0.99', width: 2, styles: PosStyles(align: PosAlign.right)),
      PosColumn(
          text: '1.98', width: 2, styles: PosStyles(align: PosAlign.right)),
    ]);

It only prints 1.98 aligned to the right.

Bad state: Future already completed

Printing throws this exception:

Bad state: Future already completed
I/flutter ( 9568): #0 _AsyncCompleter.complete (dart:async/future_impl.dart:43:31)
I/flutter ( 9568): #1 PrinterBluetoothManager.writeBytes. (package:esc_pos_bluetooth/src/printer_bluetooth_manager.dart:117:23)
I/flutter ( 9568):
I/flutter ( 9568): #2 PrinterBluetoothManager.writeBytes. (package:esc_pos_bluetooth/src/printer_bluetooth_manager.dart)
I/flutter ( 9568): #3 _rootRunUnary (dart:async/zone.dart:1198:47)
I/flutter ( 9568): #4 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
I/flutter ( 9568): #5 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
I/flutter ( 9568): #6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
I/flutter ( 9568): #7 _DelayedData.perform (dart:async/stream_impl.dart:611:14)
I/flutter ( 9568): #8 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
I/flutter ( 9568): #9 _PendingEvents.schedule. (dart:async/stream_impl.dart:687:7)
I/flutter ( 9568): #10 _rootRun (dart:async/zone.dart:1182:47)
I/flutter ( 9568): #11 _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter ( 9568): #12 _CustomZone.runGuarded (dart:async/zone.dart:997:7)

can not pair with HM-A300 printer

W/BluetoothAdapter(23880): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothBasicPlugin(23880): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
E/flutter (20762): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Bad state: Future already completed
E/flutter (20762): #0 _AsyncCompleter.complete (dart:async/future_impl.dart:43:31)
E/flutter (20762): #1 PrinterBluetoothManager.writeBytes. (package:esc_pos_bluetooth/src/printer_bluetooth_manager.dart:117:23)
E/flutter (20762):
E/flutter (20762): #2 PrinterBluetoothManager.writeBytes. (package:esc_pos_bluetooth/src/printer_bluetooth_manager.dart)
E/flutter (20762): #3 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (20762): #4 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (20762): #5 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (20762): #6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (20762): #7 _DelayedData.perform (dart:async/stream_impl.dart:611:14)
E/flutter (20762): #8 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
E/flutter (20762): #9 _PendingEvents.schedule. (dart:async/stream_impl.dart:687:7)
E/flutter (20762): #10 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (20762): #11 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (20762): #12 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (20762): #13 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
E/flutter (20762): #14 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (20762): #15 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (20762): #16 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (20762): #17 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
E/flutter (20762): #18 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (20762): #19 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (20762):
E/MethodChannel#flutter_bluetooth_basic/methods(23880): Failed to handle method call
E/MethodChannel#flutter_bluetooth_basic/methods(23880): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.cancel()' on a null object reference
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at com.tablemi.flutter_bluetooth_basic.FlutterBluetoothBasicPlugin.disconnect(FlutterBluetoothBasicPlugin.java:250)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at com.tablemi.flutter_bluetooth_basic.FlutterBluetoothBasicPlugin.onMethodCall(FlutterBluetoothBasicPlugin.java:113)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at android.os.MessageQueue.next(MessageQueue.java:330)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at android.os.Looper.loop(Looper.java:169)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at android.app.ActivityThread.main(ActivityThread.java:7094)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
E/MethodChannel#flutter_bluetooth_basic/methods(23880): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)
E/flutter (23880): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.cancel()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.cancel()' on a null object reference
E/flutter (23880): at com.tablemi.flutter_bluetooth_basic.FlutterBluetoothBasicPlugin.disconnect(FlutterBluetoothBasicPlugin.java:250)
E/flutter (23880): at com.tablemi.flutter_bluetooth_basic.FlutterBluetoothBasicPlugin.onMethodCall(FlutterBluetoothBasicPlugin.java:113)
E/flutter (23880): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (23880): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (23880): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter (23880): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (23880): at android.os.MessageQueue.next(MessageQueue.java:330)
E/flutter (23880): at android.os.Looper.loop(Looper.java:169)
E/flutter (23880): at android.app.ActivityThread.main(ActivityThread.java:7094)
E/flutter (23880): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (23880): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
E/flutter (23880): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)

Bump esc_pos_utils to 0.4.5

Is it possible to bump to the latest esc_pos_utils? In our app we use both esc_pos_bluetooth and esc_pos_printer and we cannot upgrade esc_pos_printer to the latest version because esc_pos_bluetooth is stuck at esc_pos_utils: ^0.3.6

No me muestra la impresora

Hola buenas tardes, baje tu ejemplo de github y lo instale en mi celular pero al escanear las impresoras no me aparece la que tengo (Zebra mz220), ya probe la impreosar con una aplicacion que se llama ESC POST Print y si manda a imprimir las pruebas como lo puedo solucionar para que me aparezcan en la aplicacion de pruebas y la que estoy haciendo.

Pdf417 barcode

Hello, I am testing this package with the esc_pos_utils 0.3.6 (since 0.4.5 doesn't seem to work yet). I read in the README that you can print PDF417 barcode using GS ( k command, but I cannot see how.

Reverse Always True

I am trying to print a text and allways reverse is true and I set to value false and the same.. help me!

iOS App Closes When Search Devices

Please someone can help me?

The steps I made where: install the needed packages, pub get, create the dart and test. ¿I forgot something?

I don't know what i'm doing wrong :(

Uses old rxdart and is incompatible with other plugins

Because every version of esc_pos_bluetooth depends on rxdart ^0.23.1 and month_picker_dialog 0.3.2 depends on rxdart ^0.24.0, esc_pos_bluetooth is incompatible with month_picker_dialog 0.3.2.

¿Can you update to the last rxdart? Thanks and sorry!

Apple store not allow

From Apple
2. 5 Performance: Software Requirements
Guideline 2.5.4 - Performance - Software Requirements

Your app declares support for bluetooth-central and bluetooth-peripheral in the UIBackgroundModes key in your Info.plist but does not provide Bluetooth Low Energy functionality. The Bluetooth Background modes are for apps that communicate to other devices using Bluetooth Low Energy and the Core Bluetooth framework.

Next Steps

To resolve this issue, please revise your app to add support for Bluetooth Low Energy communication through Core Bluetooth in your app or remove the bluetooth- values from the UIBackgroundModes key.

Resources

For more information on Core Bluetooth, please review the Core Bluetooth Framework Reference.

Print to Zebra

Tengo un problema para poder imprimir en una impresora zebra no la reconoce, como le puedo hacer para que me funcione.

Can not add esc_pos_bluetooth: ^0.2.8 to pubspec.yaml

Because every version of esc_pos_bluetooth depends on rxdart ^0.23.1 and driver depends on rxdart ^0.24.0, esc_pos_bluetooth is forbidden.

So, because driver depends on esc_pos_bluetooth ^0.2.8, version solving failed.
pub get failed (1; So, because driver depends on esc_pos_bluetooth ^0.2.8, version solving failed.)

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.