AllBluetooth class

Constructors

AllBluetooth()

Properties

discoverDevices Stream<BluetoothDevice>
This stream is used to listen for new bluetooth devices. In other words, this stream emits new bluetooth devices. Unlike the getBondedDevices function which returns a list of bluetooth devices, this stream emits one device at a time so you would want to store the device in a list when it is emitted. For instance
no setter
hashCode int
The hash code for this object.
no setterinherited
instance AllBluetoothPlatform
final
listenForConnection Stream<ConnectionResult>
This stream is used to listen for bluetooth connections. This connection contains the ConnectionResult, that is, the status, the response message of that connection, and if the connection was successful, there will also be a BluetoothDevice object also.
no setter
listenForData Stream<String?>
The stream for listening for data/messages across a bluetooth connection. Make sure you use it with the listenForConnection stream so that you will be sure you are send across a proper connection
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
streamBluetoothState Stream<bool>
This stream is used to listen to the state of your device's bluetooth, whether it is turned on/off.
If you change the state of your device bluetooth, this stream will emit a value corresponding to that state. So if you turn the bluetooth on, you get true and vice versa.
no setter

Methods

closeConnection() Future<void>
This function is used to close your bluetooth connection with another device and release all resources that was taken by the bluetooth connection.
connectToDevice(String address) Future<void>
This function is used to connect to another bluetooth device, using the other device's address. For this function to be successful, make sure the other device is connecting as a server because you connecting are the client
getBondedDevices() Future<List<BluetoothDevice>>
This function simply returns a list of BluetoothDevice that your phone have bonded to them before.
isBluetoothOn() Future<bool>
This simply returns true if bluetooth is turned on and false if it is turned off
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendMessage(String message) Future<bool>
Use this function to send data across your bluetooth connection. Your data is sent as raw text so you might want to perform your own encoding to ensure security when send and receiving the data.
startBluetoothServer() Future<void>
This function is used to open a server socket if you want to connect as a server. The opened socket will keep listening for clients unless you explictly close the bluetooth server with closeConnection function
startDiscovery() Future<void>
This function is used to start bluetooth discovery of unpaired or new devices. This function should be used together with discoverDevices stream in order in get discovered devices. If you are not getting the devices as expected, just call stopDiscovery, and startDiscovery again.
stopDiscovery() Future<void>
This function is used to stop bluetooth discovery.
toString() String
A string representation of this object.
inherited

Operators

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