Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop listening to HTML events, in Dart?

Tags:

dart

I am listening for click events like this:

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

How do I stop listening?

like image 384
Seth Ladd Avatar asked Feb 20 '13 23:02

Seth Ladd


1 Answers

Because onClick returns a StreamSubscription, you can cancel() it to stop receiving events.

Here is an example:

import 'dart:async';

// ...

var subscription = element.onClick.listen((e) => doCoolStuff());
// later
subscription.cancel();
like image 138
Seth Ladd Avatar answered Sep 19 '22 14:09

Seth Ladd