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.

example/lib/main.dart

import 'dart:async';
import 'dart:core';

import 'package:flutter/material.dart';
import 'package:flutter_dispose_scope/flutter_dispose_scope.dart';

void main() {
  runApp(const App());
}

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(),
    );
  }
}