dispose_scope 2.1.0 copy "dispose_scope: ^2.1.0" to clipboard
dispose_scope: ^2.1.0 copied to clipboard

Simple package making it easy to dispose (aka cancel, aka close) your objects.

DisposeScope #

DisposeScope reduces the amount of boilerplate related to disposing/canceling/closing objects when no longer needed. The DisposeScope class stores references to appropriate dispose/close/cancel methods and calls them when the scope is disposed.

This package can be used by itself however it's mainly intended as base for flutter_dispose_scope and bloc_dispose_scope packages.

Usage #

import 'package:dispose_scope/dispose_scope.dart';

final disposeScope = DisposeScope();

// StreamSubscription will be cancelled when disposeScope is disposed
const Stream.empty().listen((event) {}).disposedBy(disposeScope);

// Timer will be cancelled when disposeScope is disposed
Timer(Duration.zero, () {}).disposedBy(disposeScope);

disposeScope.dispose();

Supported types #

This package contains extension methods for dart standard library classes requiring clean up. For additional extension methods checkout flutter_dispose_scope and bloc_dispose_scope.

12
likes
160
points
46.4k
downloads

Publisher

verified publisherodrowaz.dev

Weekly Downloads

Simple package making it easy to dispose (aka cancel, aka close) your objects.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

meta

More

Packages that depend on dispose_scope