endTyping static method

dynamic endTyping({
  1. required String receiverUid,
  2. required String receiverType,
})

method to inform the receiver that the logged in user has ended typing.

receive this information in the onTypingStarted() method of the MessageListener class

Migration Note: Migrated from platform channels to native Dart implementation. Uses RealtimeRepository for sending typing indicators via WebSocket. Behavior and signature remain identical for backward compatibility.

Android Reference: CometChat.endTyping()

method could throw PlatformException with error codes specifying the cause

Implementation

static endTyping(
    {required String receiverUid, required String receiverType}) async {
  try {
    // Get SDK instance
    final sdk = SdkRegistry.getInstance();

    // Get logged-in user
    final loggedInUser = sdk.auth.getLoggedInUser();
    if (loggedInUser == null) {
      throw CometChatException(
        ErrorCode.errorUserNotLoggedIn,
        ErrorMessage.errorMessageUserNotLoggedIn,
        ErrorMessage.errorMessageUserNotLoggedIn,
      );
    }

    final indicator = TypingIndicator(
      sender: loggedInUser,
      receiverId: receiverUid,
      receiverType: receiverType,
      typingStatus: TypingIndicator.typingEnd,
      lastTimestamp: DateTime.now(),
    );

    // Send via realtime repository
    await sdk.realtime.endTyping(indicator);
  } catch (e) {
    throw e;
  }
}