NativeBluetooth class

The native interface to the browser's navigator.bluetooth object. This allows for the replacement of this interface if needed for testing.

Because of the low level interface it doesn't have any type safety.

For testing you can replace the JSUtils used using testingSetJSUtils this way you can keep everything as proper Dart objects and have the tests run under Dart native.

Annotations
  • @visibleForTesting

Constructors

NativeBluetooth()
Create a new instance of NativeBluetooth with the default implementations for the methods that will call the actual methods on the navigator in the background.

Properties

availabilityChanged → Stream<WebBluetoothValueEvent<JSBoolean>>
An event fired when the bluetooth adapter becomes available or unavailable.
no setter
hashCode → int
The hash code for this object.
no setterinherited
onAdvertisementReceived → Stream<BluetoothAdvertisementReceivedEvent>
An event fired when an advertisement packet is received.
no setter
onCharacteristicValueChanged → Stream<Event>
An event fired on an characteristic when the characteristic value has changed.
no setter
onGattServerDisconnected → Stream<Event>
An event fired when the gatt server disconnects. Either the NativeBluetoothRemoteGATTServer.disconnect method was called. Or the device is out of range/ turned off.
no setter
onServiceAdded → Stream<Event>
An event fired on a device when a service has been added.
no setter
onServiceChanged → Stream<Event>
An event fired on a device when a service has changed.
no setter
onServiceRemoved → Stream<Event>
An event fired on a device when a service has been removed.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addEventListener(String type, EventListener? callback, [AddEventListenerOptions? options]) → void
Add a new event listener to the navigation.
getAvailability() → JSPromise<JSBoolean>
Returns a JSPromise with a JSBoolean if bluetooth is available on the current device.
getDevices() → JSPromise<JSArray<WebBluetoothDevice>>
Returns a JSPromise with an JSArray of WebBluetoothDevices.
hasGetDevices() → bool
Check to see if current NativeBluetooth implementation has the getDevices method.
hasRequestLEScan() → bool
Check to see if current NativeBluetooth implementation has the hasRequestLEScan method.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEventListener(String type, EventListener? callback, [EventListenerOptions? options]) → void
Remove an event listener that has previously been added.
requestDevice(RequestOptions options) → JSPromise<WebBluetoothDevice>
Returns a JSPromise with a WebBluetoothDevice.
requestLEScan(BluetoothLEScanOptions options) → JSPromise<BluetoothLEScan>
Request the user to start scanning for Bluetooth LE devices in the area.
toString() → String
A string representation of this object.
inherited

Operators

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