startEnabledNotifications method
Future<void>
startEnabledNotifications(
- void callback(
- bool result
)
)
override
Implementation
@override
Future<void> startEnabledNotifications(
void Function(bool result) callback) async {
var cancelStream = false;
var brodcastStream = _eventChannel.receiveBroadcastStream(
{'callbackName': 'onEnabledChanged'}).listen((event) {
if (event["status"] != "error") {
callback(event['value']);
}
cancelStream = true;
});
Timer.periodic(const Duration(milliseconds: 500), (timer) {
if (cancelStream) {
brodcastStream.cancel();
timer.cancel();
}
});
}