1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Close remote peer connections on exit

This commit is contained in:
2020-04-20 17:47:51 +02:00
parent e05323c3bb
commit ee6509bb9a
2 changed files with 21 additions and 5 deletions

View File

@ -10,8 +10,12 @@ import 'package:flutter/material.dart';
abstract class SafeState<T extends StatefulWidget> extends State<T> {
final _subscriptions = List<StreamSubscription>();
bool _unmounted = false;
@override
void dispose() {
_unmounted = true;
// Close subscriptions
_subscriptions.forEach((f) => f.cancel());
@ -20,7 +24,7 @@ abstract class SafeState<T extends StatefulWidget> extends State<T> {
@override
void setState(fn) {
if (mounted) super.setState(fn);
if (mounted && !_unmounted) super.setState(fn);
}
/// Register to a new subscription