listenNotificationState method
StreamSubscription
listenNotificationState(
- void onStateChange(
- KGattDevice device,
- bool enabled
监听主机设备订阅或取消订阅Notification
Implementation
StreamSubscription listenNotificationState(void Function(KGattDevice device, bool enabled) onStateChange) {
return KGattHandler()
.eventStream
.where((event) => event['event'] == 'NotificationStateChange' && event["entityId"] == entityId)
.listen((event) {
final device = KGattDevice.fromMap(Map.from(event['device']));
onStateChange(device, event['enabled']);
});
}