How to stop listening to HTML events in Dart?

I listen to these click events:

element.onClick.listen((e) => doCoolStuff());

How to stop listening?

+5
source share
1 answer

Since StreamSubscriptiononClick returns , you can stop receiving events.cancel()

Here is an example:

import 'dart:async';

// ...

var subscription = element.onClick.listen((e) => doCoolStuff());
// later
subscription.cancel();
+9
source

All Articles