changeState method

void changeState(
  1. CallState state
)

Primary State Change Method - Use This Instead of Direct Assignment

This method is the single source of truth for all call state changes. It updates the call's state and ensures the callback is triggered.

@param state - The new CallState to transition to

Implementation

void changeState(CallState state) {
  call?.callState = state;
  onCallStateChanged(state);

  // Post call report when call ends (regardless of who initiated the BYE)
  // Also post on dropped state (network loss) — matches iOS behaviour
  // Use unawaited - don't block state change on stats/network operations
  if (state == CallState.done || state == CallState.dropped) {
    unawaited(call?._stopStatsAndPostReport());
  }
}