lastValueStream property

Stream<List<int>> get lastValueStream

this stream emits values:

  • anytime read() is called
  • anytime write() is called
  • anytime a notification arrives (if subscribed)
  • and when first listened to, it re-emits the last value for convenience

Implementation

Stream<List<int>> get lastValueStream => _mergeStreams([
      FlutterBluePlusPlatform.instance.onCharacteristicReceived,
      FlutterBluePlusPlatform.instance.onCharacteristicWritten
    ])
        .where((p) => p.remoteId == remoteId)
        .where((p) => p.primaryServiceUuid == primaryServiceUuid)
        .where((p) => p.serviceUuid == serviceUuid)
        .where((p) => p.characteristicUuid == characteristicUuid)
        .where((p) => p.instanceId == instanceId)
        .where((p) => p.success == true)
        .map((c) => c.value)
        .newStreamWithInitialValue(lastValue);