usb_plugin

Creator: coderz1093

Last updated:

0 purchases

usb_plugin Image
usb_plugin Images
Add to Cart

Description:

usb plugin

usb_plugin #
An Android USB Plugin Flutter Plugin
This plugin allows Flutter code to detect USB devices connected to your Android device.
Getting Started #
Add a dependency to your pubspec.yaml
dependencies:
usb_plugin: ^0.0.1
copied to clipboard
include the usbserial package at the top of your dart file.
import 'package:usb_plugin/usb_plugin.dart';
copied to clipboard
Check USB device is connected #
To check if any USB device is being connected to Android phone you can use the following function:
...
final _usbPlugin = UsbPlugin();
...
onPressed: () async {
int? usbState = await _usbPlugin.checkUsbState();
print(usbState); // 0-false or 1-true
}
...
copied to clipboard
Check realtime USB device is connected #
We can use Stream to check realtime USB device is connected follow by this 'stateUsbStream':

...
final _usbPlugin = UsbPlugin();
...

_usbPlugin.stateUsbStream().listen( (String data) {
print('The state of USB Connected: $data'); // 0-false or 1-true
});

copied to clipboard
FAQ #
You can ask questions through: #
https://github.com/DinhNam99/usb_plugin/issues/
Dependencies #
This library depends on:
https://github.com/DinhNam99/usb_plugin

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.