disposable_utils 1.2.0

Flutter Android iOS web

Provides a mechanism for releasing resources and utils for Dart and Flutter

disposable #

Provides a one abstract mechanism for releasing resources and utils for Dart and Flutter #

Did you notice there is no one defined method to release object resources in Dart and Flutter? StreamController.close(), StreamSubscription.cancel() and many dispose() methods in different Flutter object does the same - they free held information. But they doesn't have any one defined interface for it. Disposable does it. DisposableCollector is a composite of many disposables, which can be disposed as one. It also provides extension methods to make life easier for streams.

Do you recognize it?

class SomeDisposable {
    /// ...
    
    final _subscription = someStream.listen(
      (value) => doSomethingWith(value)
    );
    
    /// ...
    
    void dispose() {
      _subscription.cancel();
    }
}

With DisposableCollector it will looks like :

class SomeDisposable extends DisposableCollector {
  /// ...
  someStream
    .listen((value) => doSomethingWith(value))
    .addTo(this);
  
  /// ...
}

And you can make Disposable from any of your objects with factory

final disposable = Disposable.create(yourObject, () => yourObject.close());
// or
final disposable = yourObject.toDisposable(() => yourObjectClose());
0
likes
100
pub points
52%
popularity

Provides a mechanism for releasing resources and utils for Dart and Flutter

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

abramov.denis163@gmail.com

License

BSD (LICENSE)

Dependencies

flutter, mockito

More

Packages that depend on disposable_utils