W3cubDocs

/Dart 2

cancel method

Future cancel ()

Cancels this subscription.

After this call, the subscription no longer receives events.

The stream may need to shut down the source of events and clean up after the subscription is canceled.

Returns a future that is completed once the stream has finished its cleanup.

For historical reasons, may also return null if no cleanup was necessary. Returning null is deprecated and should be avoided.

Typically, futures are returned when the stream needs to release resources. For example, a stream might need to close an open file (as an asynchronous operation). If the listener wants to delete the file after having canceled the subscription, it must wait for the cleanup future to complete.

A returned future completes with a null value. If the cleanup throws, which it really shouldn't, the returned future completes with that error.

Implementation

Future cancel();

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-async/StreamSubscription/cancel.html