getStateStream method

Stream<BluetoothState> getStateStream({
  1. int timer = 1000,
})

Emits the current BluetoothState every time the adapter state changes.

Backed by CBCentralManagerDelegate.centralManagerDidUpdateState on the native side, so the stream only emits when the state actually changes (plus one initial emission on subscription once the central manager has resolved its state).

The timer parameter is kept for backwards compatibility and is ignored — the stream is event-driven, not polled.

Implementation

Stream<BluetoothState> getStateStream({int timer = 1000}) {
  return _events.receiveBroadcastStream().map((event) {
    return enumFromString(BluetoothState.values, event as String?) ??
        BluetoothState.uknow;
  });
}