0

i am trying to print on thermal printer using bluethooth but i am getting error undefined name 'PosCodeTable' i imported package esc_pos_utils and i created method called testticket to input the details in a receipt then calling the method in printReceiptBluetooth().

i used two packages
1.esc_pos_bluetooth: ^0.4.1
2.esc_pos_utils: ^1.1.0

how can solve this issue

  Future<Generator> testTicket() async{
final profile = await CapabilityProfile.load();
final Generator ticket = Generator(PaperSize.mm80,profile);

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;}

another error i am getting is undefined 'printer'

  void printReceiptBluetooth() async{
esc_pos_blue.PrinterBluetoothManager printerManager = esc_pos_blue.PrinterBluetoothManager();

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



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

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

packages i am using

 dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  webview_windows: ^0.2.2
  flutter_inappwebview: ^5.7.2+3
  http: ^0.13.5
  printing:
  pdf:
  esc_pos_printer:
  esc_pos_bluetooth: ^0.4.1
  esc_pos_utils: ^1.1.0
  flutter_html:
  file_selector: ^0.9.2+2
  file_selector_windows: ^0.9.1+4

Any help appreciated

johnson
  • 79
  • 8

0 Answers0