state property
Stream<BluetoothDeviceState>
state
The current connection state of the device
Implementation
Stream<BluetoothDeviceState> get state async* {
if (Platform.isWindows) {
yield _deviceState;
yield* _stateStream;
return;
}
yield await FlutterBluePlugin.instance._channel
.invokeMethod('deviceState', id.toString())
.then((buffer) => new protos.DeviceStateResponse.fromBuffer(buffer))
.then((p) => BluetoothDeviceState.values[p.state.value]);
yield* FlutterBluePlugin.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]);
}