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:
@ -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
|
||||
|
Reference in New Issue
Block a user