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

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

Methods

addEventListener(String type, void listener(dynamic)) → void
Add a new event listener to the navigation.
getAvailability() Object
Should return a promise (which will be converted to a future using JSUtils.promiseToFuture) with a bool if bluetooth is available on the current device.
getDevices() Object
should return a promise (which will be converted to a future using JSUtils.promiseToFuture) with a list of Objects. These objects should then be able to be converted to a WebBluetoothDevice using WebBluetoothDevice.fromJSObject.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEventListener(String type, void listener(dynamic)) → void
Remove an event listener that has previously been added.
requestDevice(RequestOptions options) Object
should return a promise (which will be converted to a future using JSUtils.promiseToFuture) with an Object. This object should then be able to be converted to a WebBluetoothDevice using WebBluetoothDevice.fromJSObject.
requestLEScan(BluetoothLEScanOptions options) Object
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