BluetoothDevice class

A Bluetooth low energy (web) device. This represents a device that (may) be connected to the browser using BLE. This is a descendant of AdvertisementBluetoothDevice with an actual gatt server so it can communicate with the BluetoothServices and BluetoothCharacteristics of the device.

You can get a BluetoothDevice by calling FlutterWebBluetooth.requestDevice or FlutterWebBluetooth.requestAdvertisementDevice.

Inheritance

Constructors

BluetoothDevice(WebBluetoothDevice bluetoothDevice)
A constructor for a new device.

Properties

advertisements Stream<AdvertisementReceivedEvent<BluetoothDevice>>
A stream which will emit all the advertisements received.
no setter
advertisementsUseMemory bool
This is a setting for this device if it should use memory for advertisements
getter/setter pair
connected Stream<bool>
A stream that gives the current connection state.
no setter
gatt NativeBluetoothRemoteGATTServer?
Get the underlying native (web) gatt service.
no setter
hasForget bool
Check to see if the browser/ user agent has forget.
no setter
hasGATT bool
Check to see if the device currently has a GATT connection.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
Get the id of the device.
no setterinherited
isForgotten bool
A bool representing if the device has already been forgotten.
no setter
name String?
A human readable name of the device.
no setterinherited
nativeDevice WebBluetoothDevice
Get the underlying native (web) bluetooth device.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
services Stream<List<BluetoothService>>
A Stream with a list of all the BluetoothService that have been discovered on this device.
no setter
watchingAdvertisements bool
If the device is watching for advertisements. If advertisements are not unsupported then it will always return false.
no setter

Methods

connect({Duration? timeout = const Duration(seconds: 5)}) Future<void>
Connect to the device's GATT server.
disconnect() → void
Disconnect from the device.
discoverServices() Future<List<BluetoothService>>
Discover the primary services on this device.
forget() Future<void>
Forget the device. This means that the device will no longer show up in FlutterWebBluetooth.devices stream.
hasWatchAdvertisements() bool
Check to see if the current browser supports the watchAdvertisements call. This can be used to avoid the NativeAPINotImplementedError.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
unwatchAdvertisements() Future<void>
Stop watching for advertisements.
watchAdvertisements([Duration? timeout]) Future<void>
Watch for advertisements from this device. The advertisements will be received using the advertisements Stream. You can choose to only watch advertisements for a specific amount of times in that case use the timeout variable. If this is null then it will watch advertisements for as long as the device is in range. Do note that not every device will keep sending out advertisements.

Operators

operator ==(Object other) bool
Check to see if two device have the same id.
inherited