easy_dispose 1.0.0 copy "easy_dispose: ^1.0.0" to clipboard
easy_dispose: ^1.0.0 copied to clipboard

outdated

Common interface to dispose different things. Always call dispose() instead of cancel(), stop(), etc.

example/main.dart

import 'dart:async';

import 'package:easy_dispose/easy_dispose.dart';
// ignore_for_file: no-empty-block
void main() {
  var myDisposableOwner = MyDisposableOwner();

  // do something

  myDisposableOwner.dispose();
}

class MyDisposableOwner extends DisposableOwner {
  final StreamController streamController = StreamController();
  final Timer timer = Timer(
    Duration(seconds: 5),
    () async {},
  );

  MyDisposableOwner(): super(
    disposeOrder: DisposeOrder.lifo,
  ) {
    addCustomDisposable(() => print('Final dispose'));
    streamController.disposeWith(this);
    timer.disposeWith(this);

    streamController.stream
        .listen(
          (_) {},
        )
        .disposeWith(this);
    addCustomDisposable(() => print('First dispose'));
  }
}
1
likes
0
pub points
63%
popularity

Publisher

unverified uploader

Common interface to dispose different things. Always call dispose() instead of cancel(), stop(), etc.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on easy_dispose