FakeBleCentralPlatform class

A scriptable, in-memory BleCentralPlatform for tests.

Inheritance

Constructors

FakeBleCentralPlatform({bool supported = true, BluetoothAdapterState adapterState = BluetoothAdapterState.on})

Properties

connectError Object?
If set, connect throws this instead of returning a connection.
getter/setter pair
connections List<FakeGattConnection>
Connections handed out by connect, in order.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scanError Object?
If set, the scan stream emits this error after any scanResults.
getter/setter pair
scanResults List<BleScanResult>
Sightings emitted (in order) when startScan is listened to.
final
scanStarted bool
getter/setter pair
scanStopped bool
getter/setter pair
supported bool
getter/setter pair

Methods

adapterState() Future<BluetoothAdapterState>
override
adapterStateChanges() Stream<BluetoothAdapterState>
Adapter-state stream. Always emits the current state on listen. Live transition events are emitted by the Linux (BlueZ) backend; macOS, iOS, Android and Windows currently emit the current state once (continuous change events on those platforms are a future enhancement). Use adapterState for a one-shot snapshot.
override
connect(DeviceId id, {Duration? timeout}) Future<GattConnection>
Opens a GATT connection to the device with id.
override
dispose() Future<void>
Releases global resources held by the backend.
override
emitAdapterState(BluetoothAdapterState state) → void
isSupported() Future<bool>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setAdapterEnabled(bool enabled) Future<void>
override
startScan({List<Uuid>? withServices}) Stream<BleScanResult>
Streams advertisement sightings, optionally filtered to withServices. Cancelling the subscription (or stopScan) stops the scan.
override
stopScan() Future<void>
override
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

sampleDevice({String address = 'AA:BB:CC:DD:EE:FF', String name = 'Test Device', int? rssi}) BleDevice
A ready-made sample device.