onTypingIndicator static method

Stream<TypingIndicator> onTypingIndicator()

Returns a stream of TypingIndicator events for real-time typing status.

Old SDK (v4 - Platform Channels): Used EventChannel('cometchat_typing_stream') and returned Stream<String>. However, the typingStreamSink was never actually used to emit data on the native side. Typing events were instead emitted through the shared EventChannel('cometchat_message_stream') via messageStreamSink, serialized as a HashMap<String, Any?> with keys:

  • receiverId (String) — ID of the receiver (user UID or group GUID)
  • receiverType (String) — "user" or "group"
  • metadata (Map?) — additional metadata from the native TypingIndicator
  • sender (Map) — serialized User or Group map of the typing user
  • methodName (String) — "onTypingStarted" or "onTypingEnded" On the Dart side, initializetestmessageStream() parsed these maps via TypingIndicator.fromMap(e) and dispatched to MessageListener callbacks.

New SDK (Native Dart): Returns Stream<TypingIndicator> from RealtimeRepository.typingStream. Each event is a TypingIndicator object with fields:

Migration:

  • Return type changed from Stream<String> to Stream<TypingIndicator>.
  • No need to check methodName — use TypingIndicator.typingStatus instead ("started" or "ended"), or use TypingStatusHelper.isTypingStarted().
  • No EventChannel dependency — works on all platforms including web.
  • MessageListener callbacks continue to work unchanged.

Implementation

static Stream<TypingIndicator> onTypingIndicator() {
  final sdk = SdkRegistry.getInstance();
  return sdk.realtime.typingStream;
}