I have a flutter application that makes use of a thermal printer, when the following format is printed:
C. | Order |
---|---|
1 | Order one description long too and more |
2 | Order two description long too and more |
If the column order is quite long, only the part where it reaches the row is printed.
I am using the following packages for printing:
- print_bluetooth_thermal: ^1.0.9
- esc_pos_utils: ^1.1.0
This piece of code is where the print command is added.
final Generator ticket = Generator(paper, profile);
List<int> bytes = [];
String product = _cleanText(detail['product'].toString());
bytes += ticket.row([
PosColumn(text: detail['amount'].toString(), width: 1),
PosColumn(text: product, width: 11)
]);
It is required that if the order does not reach the row, it is printed on the next line.
The result should be like this:
C. | Order |
---|---|
1 | Order one description long |
too and more | |
2 | Order two description long |
too and more |
2
Answers
To print text in more than one row on a thermal printer in a Flutter application, you might need to split the text into multiple lines manually and then print each line separately. You can create a function to handle the splitting of the text based on the maximum width of the text that the printer can handle on a single line.
Here’s how you could modify your code:
use log instead of print. Remember to import import ‘dart:developer’ as developer.