Skip to content

Flutter SDK chat messages incompatible with web useChat protocol #520

@Alluri-Sahiti

Description

@Alluri-Sahiti

Flutter SDK chat messages incompatible with web useChat protocol

SDK versions affected

  • livekit_client (Flutter): latest
  • @livekit/components-react (Web): latest

Problem

The @livekit/components-react web SDK has a built-in useChat hook that sends and receives chat messages over the lk-chat data channel topic using a specific JSON protocol:

{ "id": "<uuid>", "message": "hello", "timestamp": 1234567890 }

The Flutter SDK has no equivalent built-in chat implementation. When Flutter clients need to send chat messages, they must publish raw data manually — either as plain text or custom JSON — on the same lk-chat topic. This creates two incompatibilities:

1. Flutter → Web: participant name lost

When a Flutter client publishes a message on lk-chat, the web useChat hook either ignores it (if it doesn't match the expected schema) or renders it without the correct sender name. The web DataReceived handler receives the participant object, but since the message bypasses useChat internals, name resolution has to be done manually via room.remoteParticipants — which is fragile and breaks in edge cases (e.g. when the sender is the local participant).

2. Web dual-send echo causes ghost messages

As a workaround, web clients intercept publishData on the lk-chat topic and send two copies — the original JSON (for useChat) and a plain-text copy (for Flutter). The plain-text copy arrives back at other web participants' DataReceived handlers, where it bypasses useChat and gets injected into the chat DOM via manual DOM manipulation, appearing with no sender name or as 'Mobile User'.


Root cause

There is no standardised cross-platform chat protocol across LiveKit SDKs. The lk-chat topic and its JSON schema exist only in @livekit/components-react and are undocumented as a cross-SDK contract. Flutter has no useChat equivalent, so cross-platform chat requires fragile workarounds.


Expected behaviour

Either:

  • The Flutter SDK provides a built-in chat API (useChat equivalent) that publishes messages in the same { id, message, timestamp } format on the lk-chat topic, OR
  • The lk-chat protocol is formally documented as a cross-SDK standard so third-party implementations (Flutter, Unity, etc.) can be compatible by default

Workaround currently in use

We are intercepting publishData on the web side to dual-send messages, and using MutationObserver + manual DOM injection to render Flutter messages inside the LiveKit chat UI. This is brittle and breaks whenever the LiveKit chat DOM structure changes.


Questions

  1. Is there a recommended approach for cross-platform chat between Flutter and web clients in the same room?
  2. Are there plans to add a built-in chat API to the Flutter SDK?
  3. Should lk-chat be treated as a stable cross-SDK protocol contract?

Environment

  • Flutter client: Android + iOS
  • Web client: Next.js + @livekit/components-react
  • Both clients in the same LiveKit room
  • LiveKit Cloud

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions