Open
Description
Modify .monitorCharacteristic()
methods to accept additional callback with an argument of type Future<void>
. This way the user of the library is able run logic depending on the notification being turned on.
Proposed API change:
class Peripheral {
...
Stream<CharacteristicWithValue> monitorCharacteristic(
String serviceUuid,
String characteristicUuid, {
String transactionId,
void Function(Future<void>) onNotificationsTurnedOnCallback = (_) {},
})
...
}
Example:
async onNotificationsTurnedOn() {
await peripheral.writeCharacteristic(...);
}
...
peripheral.monitorCharacteristic(
"<serviceUuid>",
"<characteristicUuid>",
onNotificationsTurnedOnCallback = async (future) {
await future;
onNotificationsTurnedOn();
}).listen((value) => print(value););