usb_thermal_printer_web 0.0.3 copy "usb_thermal_printer_web: ^0.0.3" to clipboard
usb_thermal_printer_web: ^0.0.3 copied to clipboard

A package that allows you to connect your Flutter Web with thermal printer via USB and print.

This package helps you to connect to your thermal usb printer via USB in Flutter Web and print. It has been tested in MP583 thermal printer.

Features #

printText: It allows you to print a simple text. You can center align or bold the text if you want to.

printEmptyLine: It prints an empty line to add a space between two printed statements

printDottedLine: It prints a dotted line or you can use it as a divider

printRow: It takes two inputs and prints them as separate columns within a row. It is very helpful if you want to print key-value pairs i.e., product name and sale price.

printBarcode: It prints the barcode and prints the given barcode String beneath the barcode.

Getting started #

You should have a web project as this package only supports Flutter Web for now. Before starting the printing, you need to call the pairDevice() function and provide the vendorId, productId, interfaceNumber, and endpointNumber. The vendorId and productId are required and you can find them in the device description or check directly from your system by connecting it via USB. The interfaceNumber and endpointNumber are default set as 0 and 1 respectively which works for most cases. However, if it does not works, try to find the correct ones and change accordingly.

Usage #

The function below prints a sample receipt. NOTE: You may have to change the vendorId, productId, and may also provide interfaceNumber and endpointNumber to the function pairDevice().

//Create an instance of printer
  WebThermalPrinter _printer = WebThermalPrinter();

// A Dummy Function that you can call on any button and test.

printReceipt()
async
{
  
  //Pairing Device is required.
  await _printer.pairDevice(vendorId: 0x6868, productId: 0x0200);
  
  await _printer.printText('DKT Mart',
      bold: true, centerAlign: true);
  await _printer.printEmptyLine();
  
  await _printer.printRow("Products", "Sale");
  await _printer.printEmptyLine();
  
  for (int i = 0; i < 10; i++) {
    
    await _printer.printRow('A big title very big title ${i + 1}',
        '${(i + 1) * 510}.00 AED');
    await _printer.printEmptyLine();
    
  }
  
  await _printer.printDottedLine();
  await _printer.printEmptyLine();
  
  await _printer.printBarcode('123456');
  await _printer.printEmptyLine();
  
  await _printer.printEmptyLine();
  await _printer.closePrinter();
}
20
likes
120
points
435
downloads

Publisher

unverified uploader

Weekly Downloads

A package that allows you to connect your Flutter Web with thermal printer via USB and print.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, usb_device

More

Packages that depend on usb_thermal_printer_web