Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestDevices very unreliable with newest Flutter #15

Open
iKK001 opened this issue Nov 24, 2024 · 0 comments
Open

requestDevices very unreliable with newest Flutter #15

iKK001 opened this issue Nov 24, 2024 · 0 comments

Comments

@iKK001
Copy link

iKK001 commented Nov 24, 2024

Updating to Flutter 3.24.5 leads to new errors:

The biggest problem of your library seems the usbDevice.requestDevices([]) cmd !

It is very error prone.

Below is how I use it.

In debug-mode it leads to the error:

"TypeError: Instance of '_USBDevice': type '_USBDevice' is not a subtype of type 'UsbDevice?'"

In release-mode on my local machine it actually works !!

In release-mode on a remote server it leads to the error:

Null check operator used on a null value

Here is my code :
(again, it all happens at the step requestDevices !!!)

UsbDevice? _pairedDevice;
final UsbDevice usbDevice = UsbDevice();

Future<void> _connectToDevice() async {
  try {
    _pairedDevice = await usbDevice.requestDevices(
      [DeviceFilter(vendorId: 0x303a, productId: 0x1001)],
    );

    final deviceInfo = await usbDevice.getPairedDeviceInfo(_pairedDevice!);
    setState(() {
      _status = 'Connected to ${deviceInfo.productName}';
    });
  } catch (e) {
    Utils.showSnackBar(e.toString(), Colors.red);
    setState(() => _status = 'Error: $e');
  }
}

There is so much hiddenly going on with the requestDevices method. Is there any way to somehow debug this on the remote server ? Or can you explain what it does exactly ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant