flutter_disposebag

Last updated:

0 purchases

flutter_disposebag Image
flutter_disposebag Images
Add to Cart

Description:

flutter disposebag

flutter_disposebag #
Author: Petrus Nguyễn Thái Học #





A package to help disposing Streams and closing Sinks easily for Flutter.
Automatically disposes StreamSubscription and closes Sink when disposing State<T>.

Medium article #
How to easily cancel streams in Flutter
Usage #
A simple usage example:
import 'dart:async';

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

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with DisposeBagMixin {
final controller = StreamController<int>();

@override
void initState() {
super.initState();

Stream.periodic(const Duration(milliseconds: 500), (i) => i)
.listen((event) {})
.disposedBy(bag);

controller.stream.listen((event) {}).disposedBy(bag);
controller.disposedBy(bag);
}

@override
Widget build(BuildContext context) {
return Container();
}
}
copied to clipboard
Features and bugs #
Please file feature requests and bugs at the issue tracker.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.