connectionState property
Stream<BluetoothConnectionState>
get
connectionState
The current connection state of our app to the device
Implementation
Stream<BluetoothConnectionState> get connectionState {
// initial value - Note: we only care about the current connection state of
// *our* app, which is why we can use our cached value, or assume disconnected
BluetoothConnectionState initialValue =
BluetoothConnectionState.disconnected;
if (FlutterBluePlus._connectionStates[remoteId] != null) {
initialValue = _bmToConnectionState(
FlutterBluePlus._connectionStates[remoteId]!.connectionState);
}
return FlutterBluePlus._methodStream.stream
.where((m) => m.method == "OnConnectionStateChanged")
.map((m) => m.arguments)
.map((args) => BmConnectionStateResponse.fromMap(args))
.where((p) => p.remoteId == remoteId)
.map((p) => _bmToConnectionState(p.connectionState))
.newStreamWithInitialValue(initialValue);
}