flserial
0.7.3, released 4 months ago by glpro.pl
A high-performance, asynchronous serial port plugin for Flutter using Dart FFI and Native Assets.
What it does
It enables communication with serial and RS232 devices across Windows, Linux, macOS, Android, and Web. It uses a native C++ worker thread for async I/O and provides a reactive stream for incoming data and device events.
AI-written summary of version 0.7.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to communicate with RS232, USB-serial adapters, or hardware COM ports from Flutter.
- You require cross-platform serial port support including desktop, Android, and web browsers.
Skip it when
- You are targeting Firefox or Safari on the web, as they do not support the Web Serial API.
- You only need high-level network communication (such as HTTP or WebSockets).
Strengths
- Asynchronous I/O via native C++ worker thread keeps the UI thread free.
- Reactive stream interface for incoming data and events.
- Supports Native Assets on desktop and Android USB Host API without manual library copying.
Weaknesses
- Modem control lines and some configurations are not supported on the web platform.
- Android requires specific USB host permissions configured in the manifest.
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 4
For Android, add the uses-feature tag for usb.host in AndroidManifest.xml. On the web, works in Chrome and Edge 89+.
import 'dart:typed_data';
import 'package:flserial/flserial.dart';
final serial = FlSerial();
serial.events.listen((event) {
if (event.type == SerialEventType.data) {
print('Received: ${String.fromCharCodes(event.data as Uint8List)}');
}
});
final ports = await FlSerial.availablePorts();
final ok = await serial.open(ports.first.path, SerialConfig(baudRate: 115200));Alternatives
Packages that do the same job and could replace flserial.
- flutter_reactive_ble
Reactive BLE plugin for Android and iOS that supports multiple devices
86Compare - dart_periphery
Dart FFI bindings for Linux peripheral I/O (GPIO, I2C, SPI, etc.).
83Compare - serial_port_win32
A SerialPort library using win32 API for connecting real devices via serial port on Windows.
64Compare - device_manager
Manager for hardware devices and WM_DEVICECHANGE notifications on Windows and Android.
52Compare
Works with
Packages commonly used together with flserial: ones it builds on, ones built on it, and its own family.
- hooksflserial depends on itDart API for the JSON-based protocol for package build and link hooks.
- code_assetsflserial depends on itProvides the hook protocol specification for bundling native code with Dart packages.
- ffiflserial depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- native_toolchain_cflserial depends on itInvoke the native C compiler installed on the host machine.