kechankrisna / flutter_usb_printer

GNU General Public License v3.0
6 stars 50 forks source link

Null Exception Handling #25

Closed Jerinji2016 closed 3 months ago

Jerinji2016 commented 11 months ago

Changes

1. Changed USBPrinterAdapter to singleton class.

Previously, USBPrinterAdapter().getInstance() worked same as constructor instantiating. Changed getInstance to static method and disposed the static instance on onDetachedFromEngine


2. mUsbDeviceReceiver receiver always receives null for usbDevice

Checked in Android 12 & 13, the intent extra for UsbManager.EXTRA_DEVICE is always null.
So, add the vendorId and productId to pendingIntent while requesting permissions. If UsbManager.EXTRA_DEVICE is null, then try to init usb device with vendorId and productId.


3. Moved pendingIntent from class scope to local scope

Since pending intent is only required when requesting permission, moved variable to local scope

Jerinji2016 commented 3 months ago

Any Updates on this @kechankrisna ?