title: Printing on POS USB printer from dart/flutter
body: <p>On an Android Flutter project I need to print on USB POS printers and for testing I have an Epson TM-T20. Sending raw bytes would be ideal. <code>flutter_usb_write</code> package does not work (<code>write</code> returns false) and its status is a bit concerning (no sound null-safety yet, the homepage is in Croatian and there is no issue tracker).</p>
  <p>Are there any other options?</p>
  <pre><code>Future&lt;void&gt; printOnPOS(String text) async {
    // text = String.fromCharCodes([27, 64]) + text; // Initialize printer
    text += &quot;\r\n&quot;;
    try {
      var flutterUsbWrite = FlutterUsbWrite();
      List&lt;UsbDevice&gt; devices = await flutterUsbWrite.listDevices();
      print(&quot;devices: $devices&quot;);
      var device = devices[1]; // this picks the printer, checked correct
      var port = await flutterUsbWrite.open(
        vendorId: device.vid,
        productId: device.pid,
      );
      print(&quot;port: $port&quot;);
      var rw = await flutterUsbWrite.write(Uint8List.fromList(text.codeUnits));
      print(&quot;rw: $rw&quot;);
      await flutterUsbWrite.close();
    } on PlatformException catch (e) {
      print(e.message);
    }
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>I/flutter ( 7763): devices: [UsbDevice: e0f-3 VMware Virtual USB Mouse, VMware null, UsbDevice: 4b8-e03 TM-T20, EPSON 405551460005550000]
  I/flutter ( 7763): port: UsbDevice: 4b8-e03 TM-T20, EPSON 405551460005550000
  I/flutter ( 7763): rw: false
  D/UsbDeviceConnectionJNI( 7763): close
  </code></pre>