flutter_dispose_scope 2.0.0 copy "flutter_dispose_scope: ^2.0.0" to clipboard
flutter_dispose_scope: ^2.0.0 copied to clipboard

Package supporting flutter types for dispose_scope.

BlocDisposeScope #

BlocDisposeScope adds support for flutter related types to dispose_scope package.

Usage #

import 'package:flutter_dispose_scope/flutter_dispose_scope.dart';

class App extends StatefulWidget {
  const App({Key? key}) : super(key: key);

  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> with StateDisposeScopeMixin {
  @override
  void initState() {
    super.initState();

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: SizedBox(),
    );
  }
}