Skip to content

A Flutter plugin integrated with Android-SerialPort-API

License

Notifications You must be signed in to change notification settings

wangjinbiao1985/serial_port_flutter

This branch is 14 commits ahead of, 1 commit behind BbsonLin/serial_port_flutter:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 29, 2020
00cfa7c Β· Jul 29, 2020

History

32 Commits
Jul 29, 2020
May 24, 2020
Dec 3, 2019
Jul 29, 2020
Oct 28, 2019
May 24, 2020
Nov 13, 2019
Oct 28, 2019
Dec 3, 2019
Oct 28, 2019
Dec 3, 2019
Jul 29, 2020
Jul 29, 2020
Dec 3, 2019

Repository files navigation

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

About

A Flutter plugin integrated with Android-SerialPort-API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 61.7%
  • Java 21.3%
  • Ruby 12.7%
  • Swift 3.0%
  • Objective-C 1.3%