state property

The current connection state of the device

Implementation

Stream<BluetoothDeviceState> get state async* {
  yield await FlutterBlue.instance._channel
      .invokeMethod('deviceState', id.toString())
      .then((buffer) => new protos.DeviceStateResponse.fromBuffer(buffer))
      .then((p) => BluetoothDeviceState.values[p.state.value]);

  yield* FlutterBlue.instance._methodStream
      .where((m) => m.method == "DeviceState")
      .map((m) => m.arguments)
      .map((buffer) => new protos.DeviceStateResponse.fromBuffer(buffer))
      .where((p) => p.remoteId == id.toString())
      .map((p) => BluetoothDeviceState.values[p.state.value]);
}