pos_printer_manager

This plugin allow developer to print to esc printer both wireless or bluetooth (currently support only on android). This has method to list down those printers easily.

Example

  • Bluetooth Printer
_scan() async {
    setState(() {
      _isLoading = true;
      _printers = [];
    });
    var printers = await BluetoothPrinterManager.discover();
    setState(() {
      _isLoading = false;
      _printers = printers;
    });
  }

  _connect(BluetoothPrinter printer) async {
    var paperSize = PaperSize.mm80;
    var profile = await CapabilityProfile.load();
    var manager = BluetoothPrinterManager(printer, paperSize, profile);
    await manager.connect();
    print(" -==== connected =====- ");
    setState(() {
      _manager = manager;
      printer.connected = true;
    });
  }

  _startPrinter() async {
    final content = Demo.getReceiptContent();
    var bytes = await WebcontentConverter.contentToImage(content: content);
    var service = ESCPrinterService(bytes);
    var data = await service.getBytes(paperSize: PaperSize.mm58);
    if (_manager != null) {
      _manager.writeBytes(data);
    }
  }
  • Wireless Printer
_scan() async {
    setState(() {
      _isLoading = true;
      _printers = [];
    });
    var printers = await NetworkPrinterManager.discover();
    setState(() {
      _isLoading = false;
      _printers = printers;
    });
  }

  _connect(NetWorkPrinter printer) async {
    var paperSize = PaperSize.mm80;
    var profile = await CapabilityProfile.load();
    var manager = NetworkPrinterManager(printer, paperSize, profile);
    await manager.connect();
    setState(() {
      _manager = manager;
      printer.connected = true;
    });
  }

  _startPrinter() async {
    final content = Demo.getReceiptContent();
    var bytes = await WebcontentConverter.contentToImage(content: content);
    var service = ESCPrinterService(bytes);
    var data = await service.getBytes();
    if (_manager != null) {
      _manager.writeBytes(data);
    }
  }

Supports

DeviceWirelessBluetoothUSB
Android
IOS
Macos
Desktop
Linux

*** USB: will be the set to the next plan of update

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

The plugin project was generated without specifying the --platforms flag, no platforms are currently supported. To add platforms, run flutter create -t plugin --platforms <platforms> . under the same directory. You can also find a detailed instruction on how to add platforms in the pubspec.yaml at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms.

Thank to :

Libraries

bluetooth_printer
bluetooth_printer_manager
bluetooth_printer_type
bluetooth_service
connection_response
connection_type
network_printer
network_printer_manager
network_service
pos_printer
pos_printer_manager
printer_manager