flutter_webhid 0.1.0 copy "flutter_webhid: ^0.1.0" to clipboard
flutter_webhid: ^0.1.0 copied to clipboard

Platformweb

WebHID API bindings for Dart and Flutter. Access HID devices from web applications using the modern WebHID standard.

flutter_webhid #

Dart bindings for the WebHID API using dart:js_interop.

Web only - requires Chrome/Edge 89+

Installation #

dependencies:
  flutter_webhid: ^0.1.0

Usage #

import 'package:flutter_webhid/flutter_webhid.dart';

// Check support
if (!WebHID.isSupported) return;

final webHid = WebHID.instance;

// Request device
final devices = await webHid.requestDevice(
  HidDeviceRequestOptions(
    filters: [HidDeviceFilter(vendorId: 0x1234)],
  ),
);

final device = devices.first;
await device.open();

// Read input reports
device.onInputReport.listen((event) {
  print('Report ${event.reportId}: ${event.data}');
});

// Send output report
await device.sendReport(0, Uint8List.fromList([0x01, 0x02]));

await device.close();

API #

WebHID

  • requestDevice(options) - Request user permission
  • getDevices() - Get authorized devices
  • onConnect / onDisconnect - Connection events

HidDevice

  • open() / close() / forget()
  • sendReport(reportId, data)
  • sendFeatureReport(reportId, data)
  • receiveFeatureReport(reportId)
  • onInputReport - Input report stream

Types

  • HidDeviceFilter - Filter by vendorId, productId, usagePage, usage
  • HidDeviceRequestOptions - Request options with filters

See example for more details.

License #

MIT

1
likes
140
points
64
downloads

Documentation

API reference

Publisher

verified publisherphdesign.cc

Weekly Downloads

WebHID API bindings for Dart and Flutter. Access HID devices from web applications using the modern WebHID standard.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

web

More

Packages that depend on flutter_webhid