callStateChanged method

  1. @override
void callStateChanged(
  1. Call call,
  2. CallState state
)

Implementation

@override
void callStateChanged(Call call, CallState state) {
  // Reset incoming call flag if this is a new call
  if (_currentCall?.id != call.id) {
    _lastShownCallId = null;
    debugPrint('📞 New call detected, resetting CallKit UI flag');
  }

  _currentCall = call;
  _callState = state;

  debugPrint('═══════════════════════════════════════');
  debugPrint('📞 SIP CALL STATE CHANGED');
  debugPrint('═══════════════════════════════════════');
  debugPrint('🔄 State: ${state.state}');
  debugPrint('📱 Direction: ${call.direction}');
  debugPrint('📞 Call ID: ${call.id}');
  debugPrint('📞 Call Info: ${call.toString()}');
  debugPrint('═══════════════════════════════════════');

  // Print detailed call status
  _printCallStatus(call, state);

  onCallStateChanged?.call(state);

  // Handle call events (fire and forget since callback is sync)
  _handleCallState(state).catchError((e) {
    debugPrint('Error handling call state: $e');
  });
}