state property
Stream<BluetoothDeviceState>
get
state
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) {
_lastState = BluetoothDeviceState.fromId(
p.state.value, BluetoothStatusCode.fromId(p.status));
return _lastState!;
});
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) {
_lastState = BluetoothDeviceState.fromId(
p.state.value, BluetoothStatusCode.fromId(p.status));
return _lastState!;
});
}