Open rahul-yr opened 1 year ago
Hi. I want to confirm the issue. I think the issue is related to PosColumn() constructor. If textEncoded not null we always get an Exception.
I found this code inside of the PosColumn:
if (text.isEmpty && textEncoded != null && textEncoded!.isNotEmpty) {
throw Exception(
'Only one parameter - text or textEncoded - should be passed');
}
And generator doesn't set text variable. For this reason pos column throws exception.
The answer is to add multiline:false after writing the posColumn array ,
bytes += generator.row([ PosColumn( text: 'Some text 1 + Some text 2', width: 3, styles: const PosStyles(align: PosAlign.left), ), PosColumn( text: '100', width: 6, styles: const PosStyles(align: PosAlign.center), ), PosColumn( text: '10000', width: 3, styles: const PosStyles(align: PosAlign.right), ), ], multiLine:false);
https://pub.dev/packages/esc_pos_utils
use this package
The answer is to add multiline:false after writing the posColumn array ,
bytes += generator.row([ PosColumn( text: 'Some text 1 + Some text 2', width: 3, styles: const PosStyles(align: PosAlign.left), ), PosColumn( text: '100', width: 6, styles: const PosStyles(align: PosAlign.center), ), PosColumn( text: '10000', width: 3, styles: const PosStyles(align: PosAlign.right), ), ], multiLine:false);
Its work for me, but it need to limit the length String
Below is the code I have used.
And this is the exception
Please share your thoughts on this.