@@ -13,6 +13,7 @@ import 'coordinator/open_api/coordinator_client_open_api.dart';
1313import 'coordinator/retry/coordinator_client_retry.dart' ;
1414import 'core/client_state.dart' ;
1515import 'core/connection_state.dart' ;
16+ import 'disposable.dart' ;
1617import 'errors/video_error.dart' ;
1718import 'errors/video_error_composer.dart' ;
1819import 'internal/_instance_holder.dart' ;
@@ -67,7 +68,7 @@ typedef LogHandlerFunction = void Function(
6768]);
6869
6970/// The client responsible for handling config and maintaining calls
70- class StreamVideo {
71+ class StreamVideo extends Disposable {
7172 /// Creates a new Stream Video client associated with the
7273 /// Stream Video singleton instance
7374 ///
@@ -377,6 +378,21 @@ class StreamVideo {
377378 }
378379 }
379380
381+ @override
382+ Future <void > dispose () async {
383+ _logger.i (() => '[dispose]' );
384+
385+ if (! _connectionState.isDisconnected) {
386+ await _client.disconnectUser ();
387+ }
388+
389+ _subscriptions.cancelAll ();
390+ await pushNotificationManager? .dispose ();
391+ await _state.clear ();
392+
393+ return super .dispose ();
394+ }
395+
380396 void _onEvent (CoordinatorEvent event) {
381397 final currentUserId = _state.currentUser.id;
382398 _logger.v (() => '[onCoordinatorEvent] eventType: ${event .runtimeType }' );
0 commit comments