Search packages, repositories and app categories

Package detailsv0.2.8

flutter_serial_communication

Library for serial communication. Currently supports Android USB (OTG) to communicate with Arduinos and other USB serial hardware on Android WITHOUT using root access.

Android
30-day downloads
2.1K
Likes
32
Pub points
160

Install package

flutter pub add flutter_serial_communication

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package enabling serial communication on Android devices via USB OTG, allowing interaction with Arduino and other USB serial hardware without requiring root access. It leverages Android's USB Host API to establish reliable connections for data exchange. The library is designed for developers building apps that interface with external hardware through serial protocols, such as sensors or microcontrollers. It simplifies setup and handling of serial ports in Flutter applications on Android.

Use cases

  • Connecting to Arduino via USB OTG
  • Reading sensor data from external hardware
  • Controlling IoT devices via serial protocol
  • Developing industrial or lab automation apps
  • Building mobile interfaces for embedded systems

Key features

  • USB OTG support on Android
  • No root access required
  • Simple API for serial port management
  • Real-time data streaming
  • Cross-platform compatible (Android only)
  • Built-in error handling

Suitable for

  • IoT app developers
  • Hardware interfacing projects
  • Educational robotics
  • Embedded system control apps
  • Android-only serial communication needs

Considerations

  • Limited to Android platform
  • Requires USB OTG hardware
  • May need permission handling
  • Device-specific USB compatibility
  • Not suitable for iOS or desktop

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

About Flutter Serial Communication

This library aims to ease Flutter Developers to do serial communcation with their peripherals without too much hassle.

Currently supports Android USB (OTG) to communicate with Arduinos and other USB serial hardware on Android WITHOUT using root access.

Installing

1. Install it to your flutter project

flutter pub add flutter_serial_communication

or by adding dependencies to your package's pubspec.yaml then run dart pub get

dependencies:
  flutter_serial_communication: 0.2.8

2. Import it in your .dart file

import 'package:flutter_serial_communication/flutter_serial_communication.dart';

Features

  • Doesn't require root in Android
  • Easy to use
  • Using listener for reading message & device connection status

Functions

  • Get All Available Devices:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

List<DeviceInfo> availableDevices = await _flutterSerialCommunicationPlugin.getAvailableDevices();
  • Connect:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

DeviceInfo device = DeviceInfo(); // DeviceInfo from getAvailableDevices()
int baudRate = 0; // Your device's baud rate
bool isConnectionSuccess = await _flutterSerialCommunicationPlugin.connect(device, baudRate);
  • Disconnect:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

await _flutterSerialCommunicationPlugin.disconnect();
  • Write:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

bool isMessageSent = await _flutterSerialCommunicationPlugin.write(Uint8List.fromList([0xBB, 0x00, 0x22, 0x00, 0x00, 0x22, 0x7E]));
debugPrint("Is Message Sent:  $isMessageSent");
  • Read (Listener):
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

EventChannel eventChannel = _flutterSerialCommunicationPlugin.getSerialMessageListener();
eventChannel.receiveBroadcastStream().listen((event) {
  debugPrint("Received From Native:  $event");
});
  • Device Connection Status (Listener):
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

EventChannel eventChannel = _flutterSerialCommunicationPlugin.getDeviceConnectionListener();
eventChannel.receiveBroadcastStream().listen((event) {
  debugPrint("Received From Native:  $event");
});

Implementation

Categories

Dependencies

Dependency list 1 items

  • plugin_platform_interface^2.0.2

Source repository

Projects using this package

No data available yet.