andrey-ushakov / esc_pos_printer

ESC/POS (thermal, receipt) printing for Flutter & Dart
BSD 3-Clause "New" or "Revised" License
346 stars 298 forks source link

Expose the flush method of the underlying socket #169

Open Bennik2000 opened 1 year ago

Bennik2000 commented 1 year ago

This PR exposes the flush() method of the underlying socket. The flush() function should be used before disconnecting in order to send all buffered printing commands to the printer. Under some circumstances (long print jobs, slow network, ...) the printer may not be done printing before a disconnect. Then the last few lines are not printed and the paper may not get cut.

Usage of the exposed flush() method:

await printer.flush();
printer.disconnect();