BluetoothConnectionPlugin class

A Flutter plugin for Bluetooth connectivity with machines and similar devices

Constructors

BluetoothConnectionPlugin()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

classicConnectionEvents Stream<ClassicConnectionEvent>
no setter
classicDataEvents Stream<ClassicDataEvent>
no setter
onDataReceived Stream<BluetoothData>
Stream of BluetoothData objects for backward compatibility with existing code
no setter

Static Methods

connectToDevice(String deviceAddress) Future<Map<String, dynamic>>
Connect to a Bluetooth device by address
disconnectDevice() Future<Map<String, dynamic>>
Disconnect from the current device
extractValue(String rawData) String
Extract weight value from raw data string
getConnectionState() Future<Map<String, dynamic>>
Get detailed connection state
getPairedDevices() Future<List<Map<String, dynamic>>>
Get a list of paired Bluetooth devices
initialize() Future<void>
Initialize the plugin and set up data listening
isConnected() Future<bool>
Check if a device is currently connected
listenToClassicConnection({void onConnected(String deviceAddress)?, void onDisconnected(String? reason)?, void onError(String error, String? deviceAddress)?, void onEvent(ClassicConnectionEvent)?}) StreamSubscription<ClassicConnectionEvent>
Listen to Classic Bluetooth connection events with convenience callbacks
readData() Future<BluetoothData>
Read data from the connected device
readDataFromStream({Duration? timeout}) Future<BluetoothData>
Get the last received data as BluetoothData (one-time read)
sendData(String data) Future<Map<String, dynamic>>
Send data to the connected device
startClassicDataStreaming({required void onData(ClassicDataEvent), void onConnectionChange(ClassicConnectionEvent)?, void onError(dynamic)?}) Future<StreamSubscription<ClassicDataEvent>>
startDataStreaming() Future<Map<String, dynamic>>
Start continuous data streaming (inspired by reference implementation)
stopDataStreaming() Future<Map<String, dynamic>>
Stop continuous data streaming
waitForConnection({Duration timeout = const Duration(seconds: 30)}) Future<void>
Wait for successful connection with timeout