startTyping static method
method to inform the receiver that the logged in user has started 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.startTyping()
Implementation
static startTyping(
{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.typingStart,
lastTimestamp: DateTime.now(),
);
// Send via realtime repository
await sdk.realtime.startTyping(indicator);
} catch (e) {
throw e;
}
}