ChatImageUploader typedef

ChatImageUploader = Future<String> Function(Uint8List bytes, String mimeType)

Signature for the host-provided image uploader. Called by ChatViewModel.sendMessage when the user attaches a photo and the host has wired ChatViewModel.imageUploader (or ChatWidget.imageUploader which forwards to it).

Implementation contract:

  • Upload bytes to a backing store the host owns (Firebase Storage, S3, anything CDN-served).
  • Return a HTTPS URL the chat backend can GET on its own — no auth, no signed URL with a 60 s expiry.
  • The chat backend caps downloads at 20 MB, so 8-10 MB-ish files are fine; phone originals would already be resized by the picker (default max edge 1024 px ≈ 100-300 KB).
  • Failure modes: throw. ChatViewModel will fall back to inlining the bytes as base64 so the user's message still goes through.

mimeType mirrors what the picker reported (e.g. image/jpeg).

Implementation

typedef ChatImageUploader =
    Future<String> Function(Uint8List bytes, String mimeType);