dispose_scope 2.1.0 dispose_scope: ^2.1.0 copied to clipboard
Simple package making it easy to dispose (aka cancel, aka close) your objects.
import 'dart:async';
import 'package:dispose_scope/dispose_scope.dart';
void main() {
final disposeScope = DisposeScope();
// StreamSubscription will be cancelled when disposeScope is disposed
const Stream<void>.empty().listen((dynamicevent) {}).disposedBy(disposeScope);
// Timer will be cancelled when disposeScope is disposed
Timer(Duration.zero, () {}).disposedBy(disposeScope);
disposeScope.dispose();
}