usb_plugin 0.0.1 copy "usb_plugin: ^0.0.1" to clipboard
usb_plugin: ^0.0.1 copied to clipboard

A new Flutter 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

include the usbserial package at the top of your dart file.

import 'package:usb_plugin/usb_plugin.dart';

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
}
...

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
    });

FAQ #

You can ask questions through: #

https://github.com/DinhNam99/usb_plugin/issues/

Dependencies #

This library depends on:

https://github.com/DinhNam99/usb_plugin

2
likes
140
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on usb_plugin

Packages that implement usb_plugin