usb_serial
0.5.2, released 2 years ago by bessems.dev
Flutter plugin to interact with USB serial devices connected to Android.
What it does
Allows Flutter code to communicate with USB serial hardware using FTDI, CDC, and other protocols on Android. It offers asynchronous APIs for opening ports, setting port parameters, writing data, and listening to input streams, plus transaction helpers with stream transformers.
AI-written summary of version 0.5.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to communicate with hardware like Arduino, FTDI, or CP210x devices via USB from an Android Flutter app.
- You require stream transformers or transactions to handle binary protocols or terminators over serial connections.
Skip it when
- You are building for iOS or desktop platforms where USB host serial access is not supported by this plugin.
- You only need standard networking protocols like HTTP, WebSockets, or gRPC.
Strengths
- Supports multiple USB serial hardware protocols (FTDI, CDC, CP210x, Prolific, etc.).
- Provides built-in transaction and stream transformer helpers for easier data parsing.
Weaknesses
- Android-only support.
- Requires manual native setup with intent filters and device filter XML configurations.
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 2
Requires adding intent filters and a device_filter.xml file to your AndroidManifest.xml and res/xml directory.
List<UsbDevice> devices = await UsbSerial.listDevices();
UsbPort port = await devices[0].create();
bool openResult = await port.open();
port.inputStream.listen((Uint8List event) {
print(event);
});
await port.write(Uint8List.fromList([0x10, 0x00]));Alternatives
Packages that do the same job and could replace usb_serial.
- flutter_usb_printer
Send data and work with USB printers on Android.
69Compare - device_manager
Manager for hardware devices and WM_DEVICECHANGE notifications on Windows and Android.
52Compare - flutter_serial_communication
Communicate with serial hardware and Arduinos via Android USB OTG without root access.
50Compare
Works with
Packages commonly used together with usb_serial: ones it builds on, ones built on it, and its own family.