Skip to content

Install — Flutter

Flutter widget_chat running on iOSFlutter widget_chat running on Android

Flutter is the reference SDK: it has the complete API surface (host callbacks, host slots, custom header, image uploader). The native ports track it — see Feature parity.

  1. Add the package:

    Terminal window
    flutter pub add widget_chat
  2. Mount ChatWidget. Full-page (a dedicated tab/route):

    import 'package:widget_chat/chat_widget.dart';
    ChatWidget(
    configuration: BotConfiguration(
    projectSecretKey: 'YOUR_PROJECT_SECRET_KEY',
    userID: user.id,
    // optional per-session context:
    authToken: user.jwt,
    userContext: {'pro': user.isPro},
    ),
    fullPage: true,
    );

    Or as a floating helper — omit fullPage and it renders a FAB that expands into a panel.

Wiring host integration

ChatWidget(
configuration: config,
fullPage: true,
// Route rich-content "callback" actions into native code:
onRichContentCallback: (callbackId, payload) { … },
// Upload attached photos to your storage; return an HTTPS URL:
imageUploader: (bytes, mime) async => myUploader.upload(bytes, mime),
// Render a bot-reserved `host_slot` with your own widget:
hostSlotBuilder: (slotId, payload) => MySlot(payload),
// Replace the header entirely:
headerBuilder: (context, data) => MyHeader(data),
);

See the full ChatWidget API.

Theming from the host

Install a ChatColors theme extension to override the chat-surface palette from your app (wins over the dashboard’s per-field values):

Theme(
data: appTheme.copyWith(extensions: [
...appTheme.extensions.values,
const ChatColors(
surfaceBackground: Color(0xFFFBEAEF),
botBubbleBackground: Colors.white,
userBubbleBackground: Color(0xFFB23B59),
userBubbleForeground: Colors.white,
),
]),
child: ChatWidget(configuration: config, fullPage: true),
);