esc_pos_bluetooth 0.2.7

  • Readme
  • Changelog
  • Installing
  • new86

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.

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 receipttest receipt

[0.2.7] #

  • Updated flutter_bluetooth_basic

[0.2.6] #

  • Updated flutter_bluetooth_basic

[0.2.5] #

  • Split data into chunks

[0.2.4] #

  • startScan timeout bug fixed.
  • Updated esc_pos_utils package version to 0.3.4.

[0.2.3] #

  • Updated esc_pos_utils package version to 0.3.3.

[0.2.2] #

  • Updated esc_pos_utils package version to 0.3.2.

[0.2.1] #

  • Updated esc_pos_utils package version to 0.3.1 (Open Cash Drawer).

[0.2.0] #

  • Updated esc_pos_utils package version to 0.3.0 (Image and Barcode alignment).

[0.1.1] #

  • Updated esc_pos_utils, flutter_bluetooth_basic package versions

[0.1.0] #

  • Android and iOS Bluetooth printing support

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  esc_pos_bluetooth: ^0.2.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
72
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and esc_pos_bluetooth.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
esc_pos_utils ^0.3.5 0.3.5
flutter 0.0.0
flutter_bluetooth_basic ^0.1.5 0.1.5
rxdart ^0.23.1 0.23.1 0.24.0-dev.1
Transitive dependencies
archive 2.0.13
args 1.6.0
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
gbk_codec 0.3.2
hex 0.1.2
html 0.14.0+3
image 2.1.12
json_annotation 3.0.1
meta 1.1.8
path 1.6.4
petitparser 3.0.2
sky_engine 0.0.99
source_span 1.7.0
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
xml 3.7.0 4.1.0
Dev dependencies
flutter_test