serial_port_flutter 0.1.0

Flutter Android iOS

A Flutter plugin integrated with Android-SerialPort-API, for connecting real device by serial port.

A Flutter plugin integrated with Android-SerialPort-API.

This plugin works only for Android devices.

Usage #

List devices #

Future<List<Device>> findDevices() async {
  return await FlutterSerialPort.listDevices();
}

Create SerialPort for certain device #

Device theDevice = Device("deviceName", "/your/device/path");
int baudrate = 9600;
Serial serialPort = await FlutterSerialPort.createSerialPort(theDevice, baudrate);

Open/Close device #

bool openResult = await serialPort.open();
print(serialPort.isConnected) // true
bool closeResult = await serialPort.close();
print(serialPort.isConnected) // false

Read/Write data from/to device #

// Listen to `receiveStream`
serialPort.receiveStream.listen((recv) {
  print("Receive: $recv");
});

serialPort.write(Uint8List.fromList("Write some data".codeUnits));

Example #

Check out the example.

Issues #

Build failed on Android #

If you bump into a issue like below.

Change the android:label in AndroidManifest.xml.

Check out this commit fix: 🐛 Fix Android build failed issue

3
likes
90
pub points
57%
popularity

A Flutter plugin integrated with Android-SerialPort-API, for connecting real device by serial port.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

bobson801104@gmail.com

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on serial_port_flutter