LCOV - code coverage report
Current view: top level - _session_manager - ios_cast_session_manager.dart Coverage Total Hit
Test: lcov_cleaned.info Lines: 0.0 % 35 0
Test Date: 2025-06-20 10:50:47 Functions: - 0 0

            Line data    Source code
       1              : import 'package:flutter/services.dart';
       2              : import 'package:flutter_chrome_cast/lib.dart';
       3              : import 'package:rxdart/subjects.dart';
       4              : 
       5              : /// iOS-specific implementation of Google Cast session manager functionality.
       6              : class GoogleCastSessionManagerIOSMethodChannel
       7              :     implements GoogleCastSessionManagerPlatformInterface {
       8              :   /// Creates a new iOS session manager method channel.
       9            0 :   GoogleCastSessionManagerIOSMethodChannel() {
      10            0 :     _channel.setMethodCallHandler(
      11            0 :       (call) => _methodCallHandler(call),
      12              :     );
      13              :   }
      14              : 
      15              :   final _channel = const MethodChannel('google_cast.session_manager');
      16              : 
      17            0 :   @override
      18              :   Stream<GoogleCastSession?> get currentSessionStream =>
      19            0 :       _currentSessionStreamController.stream;
      20              : 
      21              :   final _currentSessionStreamController = BehaviorSubject<GoogleCastSession?>()
      22              :     ..add(null);
      23              : 
      24            0 :   @override
      25              :   Future<bool> startSessionWithDevice(GoogleCastDevice device) async {
      26              :     device as GoogleCastIosDevice;
      27            0 :     return await _channel.invokeMethod(
      28              :       'startSessionWithDevice',
      29            0 :       device.index,
      30              :     );
      31              :   }
      32              : 
      33            0 :   @override
      34              :   GoogleCastConnectState get connectionState =>
      35            0 :       currentSession?.connectionState ?? GoogleCastConnectState.disconnected;
      36              : 
      37              :   /// Returns the current cast session if available.
      38              :   ///
      39              :   /// This method is not implemented for iOS and will throw an [UnimplementedError].
      40              :   /// Use [currentSession] instead which is properly implemented for iOS.
      41            0 :   GoogleCastSession? get currentCastSession => throw UnimplementedError();
      42              : 
      43            0 :   @override
      44              :   GoogleCastSession? get currentSession =>
      45            0 :       _currentSessionStreamController.value;
      46              : 
      47            0 :   @override
      48              :   Future<bool> endSession() async {
      49            0 :     return await _channel.invokeMethod('endSession');
      50              :   }
      51              : 
      52            0 :   @override
      53              :   Future<bool> endSessionAndStopCasting() async {
      54            0 :     return await _channel.invokeMethod('endSessionAndStopCasting');
      55              :   }
      56              : 
      57            0 :   @override
      58              :   bool get hasConnectedSession =>
      59            0 :       connectionState == GoogleCastConnectState.connected;
      60              : 
      61            0 :   @override
      62              :   Future<void> setDefaultSessionOptions() {
      63              :     // TODO: implement setDefaultSessionOptions
      64            0 :     throw UnimplementedError();
      65              :   }
      66              : 
      67            0 :   @override
      68              :   Future<bool> startSessionWithOpenURLOptions() {
      69              :     // TODO: implement startSessionWithOpenURLOptions
      70            0 :     throw UnimplementedError();
      71              :   }
      72              : 
      73            0 :   @override
      74              :   Future<bool> suspendSessionWithReason() {
      75              :     // TODO: implement suspendSessionWithReason
      76            0 :     throw UnimplementedError();
      77              :   }
      78              : 
      79            0 :   Future<dynamic> _methodCallHandler(MethodCall call) async {
      80            0 :     switch (call.method) {
      81            0 :       case 'onCurrentSessionChanged':
      82            0 :         return _onCurrentSessionChanged(call.arguments);
      83              :     }
      84              :   }
      85              : 
      86            0 :   void _onCurrentSessionChanged(dynamic arguments) async {
      87              :     try {
      88            0 :       final session = IOSGoogleCastSessions.fromMap(
      89            0 :           arguments == null ? null : Map<String, dynamic>.from(arguments));
      90            0 :       _currentSessionStreamController.add(session);
      91              :     } catch (e) {
      92              :       rethrow;
      93              :     }
      94              :   }
      95              : 
      96            0 :   @override
      97              :   void setDeviceVolume(double value) {
      98            0 :     _channel.invokeMethod('setDeviceVolume', value);
      99              :   }
     100              : }
        

Generated by: LCOV version 2.3.1-1