Search packages, repositories and app categories

Package detailsv1.0.2

usb_device

Flutter plugin to communicate with usb device (start sessions, send datas, set configurations ...).

Web
30-day downloads
674
Likes
35
Pub points
150

Install package

flutter pub add usb_device

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The usb_device package is a Flutter plugin enabling communication with USB devices on the web. It allows users to initiate sessions, send and receive data, and configure USB devices directly through web browsers that support WebUSB. Designed for device interaction in web applications, it leverages browser-level USB APIs to provide low-level access to connected peripherals. The plugin is particularly useful for developers building web-based tools that interface with hardware such as sensors, controllers, or custom devices. It supports only web platforms and requires user permission for device access.

Use cases

  • Connecting to hardware via USB in web apps
  • Sending commands to USB-connected devices
  • Reading data from external USB peripherals
  • Developing web-based device control interfaces
  • Enabling real-time communication with embedded devices

Key features

  • Web-only USB communication
  • Supports session management
  • Data transmission and reception
  • Device configuration options
  • Browser-based WebUSB integration

Suitable for

  • Web developers working with hardware
  • IoT web applications
  • Custom device control dashboards
  • Prototyping USB-enabled web tools
  • Educational projects involving USB devices

Considerations

  • Limited to web platform only
  • Requires browser support for WebUSB
  • User permission required for device access
  • No support for mobile or desktop native apps
  • Dependent on device compatibility with WebUSB

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

web usb logo



License: MIT pub dev usb_device




🚀  Overview

WebUSB plugin provide access to USB devices from Flutter Web 💙 by using web usb official API.

  • 📱 Get device info with configuration.
  • 🔌 Pair a device with filter.
  • 📤 Send data to USB device.
  • 📥 Receive data from USB device.
  • 🎛️ Change USB device configuration.

💻  Platform Support

Android iOS MacOS Web Linux Windows
➖ ➖ ➖ ✔️ ➖ ➖

📖  Installation

Install the package
flutter pub add usb_device
Import the package
import 'package:usb_device/usb_device.dart';

🚀  Get started

  • Import & instanciate the plugin.
import 'package:usb_device/usb_device.dart';

final UsbDevice usbDevice = UsbDevice();
  • Common used methods.

// get paired devices
final pairedDevices = await usbDevice.pairedDevices;

// pair a device 
final pairedDevice = await usbDevice.requestDevices([DeviceFilter(vendorId : 0x00, productId: 0x00)]);

// get device's configurations 
List<USBConfiguration> availableConfigurations = await usbDevice.getAvailableConfigurations(pairedDevice);

// get device's info
USBDeviceInfo deviceInfo = await usbDevice.getPairedDeviceInfo(pairedDevice);

// start session
await usbDevice.open(pairedDevice);

// close session
await usbDevice.close(pairedDevice);

📚  Methods

USB

Name Description Returned value
pairedDevices Get paired attached devices Future<List<dynamic>>
requestDevice(List<DeviceFilter> filters) Pair a device with filter or not Future<dynamic>
isSupported() Pair a device with filter or not Future<bool>
open() Start a session Future
close() Close a session Future
claimInterface(dynamic device, int interfaceNumber) Claim an interface for exclusive access Future
releaseInterface(dynamic device, int interfaceNumber) Release a claimed interface Future
reset(dynamic device) Reset device Future
selectConfiguration(dynamic device, int configurationValue) Select a specified configuration Future
clearHalt(dynamic device, String direction, int endpointNumber) Returns a promise that resolves when a halt condition is cleared Future
controlTransferIn(dynamic device, SetupParam setup, {int? length}) Return result of a command Future<USBInTransferResult>
controlTransferOut(dynamic device, SetupParam setup, {dynamic data}) Send a command to device Future<USBOutTransferResult>
transferIn(dynamic device, int endpointNumber, int length) Return data from device Future<USBInTransferResult>
transferOut(dynamic device, int endpointNumber, dynamic data) Send data to device Future<USBOutTransferResult>
isochronousTransferIn(dynamic device, int endpointNumber, List<int> packetLengths) Resolves with a USBIsochronousInTransferResult when time sensitive information has been transmitted to (received by) the USB device Future<USBIsochronousInTransferResult>
isochronousTransferOut(dynamic device, int endpointNumber, List<int> packetLengths) Resolves with a USBIsochronousOutTransferResult when time sensitive information has been transmitted from the USB device Future<USBIsochronousOutTransferResult>
setOnConnectCallback(Function(dynamic) onConnect) Connect callback Future
setOnDisconnectCallback(Function(dynamic) onDisconnect) Disconnect callback Future
getSelectedConfiguration(dynamic pairedDevice) Get the selected configuration Future<USBConfiguration?>
getAvailableConfigurations(dynamic pairedDevice) Get available device's configurations Future<List<USBConfiguration>>
getPairedDeviceInfo(dynamic pairedDevice) Get info of paired device Future<USBDeviceInfo>

📣  Sponsor

logo apparence io

Initiated and sponsored by Apparence.io.

👥  Contribution

Contributions are welcome. Contribute by creating a PR or create an issue 🎉.

Categories

Dependencies

Dependency list 2 items

  • usb_device_platform_interface^1.0.0
  • usb_device_web^1.0.0

Source repository

Projects using this package

No data available yet.