copyWith method

QuickRTCState copyWith({
  1. ConnectionStatus? status,
  2. String? conferenceId,
  3. String? participantId,
  4. String? participantName,
  5. List<LocalStream>? localStreams,
  6. Map<String, RemoteParticipant>? participants,
  7. String? error,
  8. bool clearError = false,
  9. bool clearConferenceId = false,
  10. bool clearParticipantId = false,
  11. bool clearParticipantName = false,
})

Create a copy of this state with the given fields replaced

Use clearError to explicitly clear the error field. Use clearConferenceId, clearParticipantId, clearParticipantName to explicitly clear those fields.

Note: The version is automatically incremented on every copyWith call to ensure state changes are always detected.

Implementation

QuickRTCState copyWith({
  ConnectionStatus? status,
  String? conferenceId,
  String? participantId,
  String? participantName,
  List<LocalStream>? localStreams,
  Map<String, RemoteParticipant>? participants,
  String? error,
  bool clearError = false,
  bool clearConferenceId = false,
  bool clearParticipantId = false,
  bool clearParticipantName = false,
}) {
  return QuickRTCState(
    version: version + 1, // Always increment version
    status: status ?? this.status,
    conferenceId:
        clearConferenceId ? null : (conferenceId ?? this.conferenceId),
    participantId:
        clearParticipantId ? null : (participantId ?? this.participantId),
    participantName: clearParticipantName
        ? null
        : (participantName ?? this.participantName),
    localStreams: localStreams ?? this.localStreams,
    participants: participants ?? this.participants,
    error: clearError ? null : (error ?? this.error),
  );
}