flutter_serial_communication 0.2.8 copy "flutter_serial_communication: ^0.2.8" to clipboard
flutter_serial_communication: ^0.2.8 copied to clipboard

PlatformAndroid

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

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
copied to clipboard

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

dependencies:
  flutter_serial_communication: 0.2.7
copied to clipboard

2. Import it in your .dart file

import 'package:flutter_serial_communication/flutter_serial_communication.dart';
copied to clipboard

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();
copied to clipboard
  • 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);
copied to clipboard
  • Disconnect:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

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

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

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

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

Implementation #

27
likes
160
points
1.22k
downloads

Publisher

verified publisherfarells.id

Weekly Downloads

2024.10.27 - 2025.09.21

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_serial_communication

Packages that implement flutter_serial_communication