serial_port_flutter 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

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;
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

0.1.0 #

  • Add constants.dart.
  • Fix Android build failed.
  • Complete for 0.1.0
  • Complete doc strings.

0.0.4 #

  • Add functions for String / Hex exchanging. (utils.dart)

0.0.3 #

  • Remove debug messages from

0.0.2 #

  • Add baudrate parameter in FlutterSerialPort.createSerialPort

0.0.1 #

  • Integrate Android-SerialPort-API functions.
  • Implement class SerialPort and Device.


This is more practical project for using serial_port_flutter

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  serial_port_flutter: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:serial_port_flutter/serial_port_flutter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/serial_port_flutter.dart.

Run flutter format to format lib/serial_port_flutter.dart.

Format lib/utils.dart.

Run flutter format to format lib/utils.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies