Flutter Chatbot UI Kit
dialogs_chatbot_flutter gives your Flutter app a complete, ready-made chatbot screen for
iOS and Android. Drop in EnxChatScreen as a route, or embed EnxChatWidget
anywhere in your layout, and you get the message list, input bar, attachments, typing indicator,
rich bot content and a built-in agent video call overlay — with only a Bot ID
and host URL. The chat engine runs in a hidden WebView and talks to Dart over a JavaScript bridge,
so no Swift or Kotlin code is needed.
First release, published on pub.dev. See Release Notes for what's included.
View on pub.devThe UI Kit and the Flutter Chatbot SDK are the same package, dialogs_chatbot_flutter. This page covers the ready-made widgets, theming and calling. The SDK page covers EnxChatController on its own — its full API, callbacks, streams and message models — for apps that build their own chat UI.
Requirements
| Requirement | Value |
|---|---|
| Flutter | 3.10.0 or later |
| Dart | 3.0.0 or later (below 4.0.0) |
| iOS | 12.0 or later |
| Android | minSdkVersion 21 (Android 5.0), with Android System WebView 67 or later |
| Platforms | iOS and Android only — no web or desktop targets |
| Network | Required at startup to load the chat engine |
Installation
Add the UI Kit to your app's pubspec.yaml. Two of its dependencies must also be declared directly in your app: flutter_inappwebview (it renders the video call overlay) and permission_handler (it requests camera and microphone access). If either is missing, the app fails at runtime with a MissingPluginException.
dependencies:
dialogs_chatbot_flutter: ^1.0.0
# Required in the host app
flutter_inappwebview: ^6.1.5
permission_handler: ^12.0.1
Then fetch the packages:
flutter pub get
Everything is exported from a single import:
import 'package:dialogs_chatbot_flutter/dialogs_chatbot_flutter.dart';
Required Permissions
The UI Kit uses the camera and photo library for attachments, and the camera and microphone for video calls. Declare the permissions below even if you start with chat only — a bot can start a call or ask for a photo at any time.
iOS
In ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required to send photos and make video calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for audio and video calls.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library access is required to send images.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Photo library access is required to save images.</string>
In ios/Podfile, set the minimum iOS version:
platform :ios, '12.0'
Android
In android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Android 13+ (API 33+) -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- Android 12 and below -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
In android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 21
}
}
What each permission is for
| Permission | Used for |
|---|---|
INTERNET | Always — loading the chat engine and the socket connection |
CAMERA / NSCameraUsageDescription | Taking a photo to send, and video calls |
RECORD_AUDIO / NSMicrophoneUsageDescription | Audio and video calls |
READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_EXTERNAL_STORAGE / NSPhotoLibraryUsageDescription | Picking images and videos from the gallery |
NSPhotoLibraryAddUsageDescription | Saving media to the photo library |
You don't need to write permission code. The UI Kit asks for camera and microphone access at runtime (through permission_handler) before a call starts. On Android, the plugin's WebViews then grant the page camera and microphone access automatically.
Pattern 1 — Full-Screen Chat
The quickest integration. EnxChatScreen is a complete Scaffold with an app bar showing the bot's name and avatar. Push it as a route, for example from a “Chat with us” button. The screen creates, starts and disposes of its own controller.
import 'package:dialogs_chatbot_flutter/dialogs_chatbot_flutter.dart';
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => EnxChatScreen(
config: const EnxBotConfig(
botId: 'YOUR_BOT_ID',
host: 'https://dialogs.enablex.io',
),
),
),
);
Pattern 2 — Embedded Widget
Use EnxChatWidget when the chat should live inside your own layout — a tab, a bottom sheet, a split view or a card. It has no app bar of its own and fills whatever space you give it.
Scaffold(
appBar: AppBar(title: const Text('Support')),
body: EnxChatWidget(
config: const EnxBotConfig(
botId: 'YOUR_BOT_ID',
host: 'https://dialogs.enablex.io',
),
theme: EnxChatTheme.mobileClassic,
onMessageReceived: (msg) => debugPrint('Bot: ${msg.text}'),
),
)
Pattern 3 — Widget with Your Own Controller
Create the EnxChatController yourself when the rest of your app needs the chat state — for example to show an unread badge, react to connection changes, or send a message from outside the chat. Pass it to EnxChatWidget.withController or EnxChatScreen.withController. You own the controller, so you call initialize() and dispose().
class ChatPage extends StatefulWidget {
const ChatPage({super.key});
@override
State<ChatPage> createState() => _ChatPageState();
}
class _ChatPageState extends State<ChatPage> {
late final EnxChatController _controller;
@override
void initState() {
super.initState();
_controller = EnxChatController(
config: const EnxBotConfig(
botId: 'YOUR_BOT_ID',
host: 'https://dialogs.enablex.io',
),
);
// Set callbacks before initialize()
_controller.onStatusChanged = (status) => setState(() {});
_controller.onError = (message, type) => debugPrint('[$type] $message');
_controller.initialize();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return EnxChatWidget.withController(
controller: _controller,
);
}
}
EnxChatController extends ChangeNotifier, so it works with Provider, Riverpod, BLoC, GetX or plain setState. For its full API, streams and callbacks, see the Flutter Chatbot SDK.
Listening to Chat Events
For simple integrations you don't need a controller to observe the chat — EnxChatScreen and EnxChatWidget take callbacks directly as constructor parameters.
EnxChatScreen(
config: config,
onMessageReceived: (EnxMessage msg) {
// Every incoming message
},
onMessageSent: (EnxMessage msg) {
analytics.track('chat_message_sent', {'type': msg.type.name});
},
onBotInfo: (Map<String, dynamic> info) {
debugPrint('Connected to ${info['name']}');
},
onError: (String message, String type) {
debugPrint('[$type] $message');
},
)
| Callback | Fires when |
|---|---|
onMessageReceived(EnxMessage) | A message arrives from the bot (or a user message is echoed back). |
onMessageSent(EnxMessage) | The user sends a message, after it is added to the list. |
onBotInfo(Map<String, dynamic>) | Bot metadata (name, avatar, welcome message, settings) arrives after connecting. |
onError(String message, String type) | The bridge, socket or a file upload reports an error. See error types. |
onAudioCall() / onVideoCall() | The user taps a call button. See Call buttons. |
Theming
EnxChatTheme sets the colours of the app bar, bubbles, background and avatars. Pass it as theme to either widget. Every field has a default, so set only what you want to change.
const myTheme = EnxChatTheme(
primaryColor: Color(0xFF1A73E8), // app bar, send button, accents
userBubbleColor: Color(0xFFE8F0FE),
botBubbleColor: Colors.white,
backgroundColor: Color(0xFFF5F5F5),
userAvatarColor: Color(0xFF1A73E8),
botAvatarColor: Color(0xFF34A853),
);
EnxChatScreen(config: config, theme: myTheme);
For a ready-made WhatsApp-style look with a compact layout, use the built-in preset:
EnxChatWidget(config: config, theme: EnxChatTheme.mobileClassic);
See EnxChatTheme for every field and its default. Theming in v1.0.0 is limited to these colour tokens and the compact layout switch — there is no API for changing the structure of the screen.
Audio & Video Calling
The UI Kit can show a live call with an agent inside your app, without you writing any call code. When the bot (or an agent behind it) starts a call, a full-screen overlay opens over the chat and loads the call page; when the call ends, the overlay closes and the user is back in the conversation.
How a call runs
Calls in the Flutter UI Kit are browser calls: the call itself is a web page, and the UI Kit shows it in its own WebView. The call is driven entirely by messages from the bot.
- The bot sends a message whose
audioVideoActionis"start"and whoseiFrameUrlis the address of the call page. EnxChatControllerstores the URL inactiveVideoCallUrland notifies its listeners.EnxChatScreen/EnxChatWidgetsees the URL and opensEnxVideoCallOverlayon top of the chat. The overlay is a separateInAppWebView(fromflutter_inappwebview) with inline media playback enabled.- The call page uses the device camera and microphone through the WebView.
- When the call ends, the bot sends a message with
audioVideoAction="stop". The controller callscloseVideoCallOverlay(),activeVideoCallUrlbecomesnull, and the overlay is dismissed.
See the call sequence diagram for the same flow step by step.
Unlike the Android Chatbot UI Kit, the Flutter UI Kit has no native call path — a call always runs from an iFrameUrl in the overlay WebView. The call page must be served over HTTPS.
Click-to-call bots
Some bots are set up as click-to-call bots: their purpose is to connect the user to a call rather than to chat. The bot's botInfo.clickToCall setting decides which interface the UI Kit shows:
botInfo.clickToCall | What the user sees |
|---|---|
"text" | The full chat interface. |
"audio" or "video" | A call-only interface instead of the chat. |
The setting is read from the server when the chat connects, so you don't configure it in the app. If your app needs to know which interface is showing (for example to change its own app bar), read controller.showClickToCallVideoOnlyUi, which is true when clickToCall is anything other than "text". To start a click-to-call session from your own code, call controller.requestClickToCallVideo().
Call buttons
The input bar can also show audio and video call buttons. To show them, set both callingEnabled: true on EnxBotConfig and showCallingOptions: true on the widget.
EnxChatScreen(
config: const EnxBotConfig(
botId: 'YOUR_BOT_ID',
host: 'https://dialogs.enablex.io',
callingEnabled: true,
),
showCallingOptions: true,
onAudioCall: () {
// The user tapped the audio call button
},
onVideoCall: () {
// The user tapped the video call button
},
)
Tapping a call button does not start the in-app call overlay. It only calls onAudioCall or onVideoCall, and your app decides what happens — for example, starting a call with your own calling SDK such as the EnableX Video Flutter SDK. The overlay opens only when the bot sends a call-start message.
Reading call state from your app
If you use your own controller (Pattern 3), these properties tell you what the call interface is doing:
| Member | Description |
|---|---|
activeVideoCallUrl | The call page URL while the overlay is open; null otherwise. |
showClickToCallVideoOnlyUi | true when the bot is a click-to-call bot and the call-only interface is shown. |
requestClickToCallVideo() | Starts the click-to-call video mode. |
closeVideoCallOverlay() | Closes the call overlay from your code. |
Because the controller is a ChangeNotifier, any widget listening to it rebuilds when a call starts or ends.
Supported Media Types
Sending (User → Bot)
The attachment button in the input bar lets the user pick a file; the UI Kit detects its MIME type and uploads it through the bridge to the EnableX CDN.
| Type | Source in the built-in input bar |
|---|---|
| Image | Camera or gallery (image_picker) |
| Video | Gallery (image_picker) |
| Document (PDF and other files) | System document picker (file_picker) |
To send a file from your own code, call controller.sendFile(bytes: ..., fileName: ..., mimeType: ...) — see Sending messages on the SDK page.
Receiving (Bot → User)
Content (EnxMessageType) | Rendered as |
|---|---|
text | Message bubble, with action link buttons when the bot attaches them |
action | One or more buttons that open a URL |
suggestion | Tappable chips — single-select chips send on tap; multi-select chips let the user pick several and then confirm |
image | Image card with title, subtitle, actions and suggestions; images are cached |
video | Video card with thumbnail and play overlay |
file | File attachment card (documents, PDFs and so on) |
system | Centred status message, for example live-agent handover |
typing | Animated three-dot bubble (EnxTypingBubble) while the bot composes a reply |
calendar | Rendered as text in v1.0.0 — a date picker is planned |
EnxChatScreen / EnxChatWidget
EnxChatScreen is a full-screen Scaffold with an app bar; EnxChatWidget is the same chat without the app bar, for embedding. Both have the same parameters and two constructors: one that creates and owns its controller from a config, and .withController, which uses a controller you created.
// The widget creates and manages its own controller
EnxChatWidget({
Key? key,
required EnxBotConfig config,
EnxChatTheme theme = const EnxChatTheme(),
bool showCallingOptions = false,
void Function(EnxMessage)? onMessageReceived,
void Function(EnxMessage)? onMessageSent,
void Function(String, String)? onError,
void Function(Map<String, dynamic>)? onBotInfo,
VoidCallback? onAudioCall,
VoidCallback? onVideoCall,
})
// You provide the controller
EnxChatWidget.withController({
Key? key,
required EnxChatController controller,
EnxChatTheme theme = const EnxChatTheme(),
bool showCallingOptions = false,
void Function(EnxMessage)? onMessageReceived,
void Function(EnxMessage)? onMessageSent,
void Function(String, String)? onError,
void Function(Map<String, dynamic>)? onBotInfo,
VoidCallback? onAudioCall,
VoidCallback? onVideoCall,
})
// EnxChatScreen(...) and EnxChatScreen.withController(...) take the same parameters
| Parameter | Type | Description |
|---|---|---|
config | EnxBotConfig | Bot configuration. Required for the default constructor. |
controller | EnxChatController | Your controller. Required for .withController; you call initialize() and dispose() on it. |
theme | EnxChatTheme | Colours and layout. Defaults to const EnxChatTheme(). |
showCallingOptions | bool | Shows the audio and video call buttons in the input bar. Default false. |
onMessageReceived | void Function(EnxMessage)? | A message was received. |
onMessageSent | void Function(EnxMessage)? | The user sent a message. |
onError | void Function(String, String)? | An error occurred: message and type. |
onBotInfo | void Function(Map<String, dynamic>)? | Bot metadata was received. |
onAudioCall | VoidCallback? | The audio call button was tapped. |
onVideoCall | VoidCallback? | The video call button was tapped. |
EnxBotConfig
An immutable, const-constructible object that identifies the bot. It is sent to the chat engine when the chat starts.
const EnxBotConfig({
required String botId,
required String host,
String rootPath = '',
bool callingEnabled = false,
})
| Field | Type | Required | Description |
|---|---|---|---|
botId | String | Yes | Bot identifier from the EnableX Dialogs dashboard. |
host | String | Yes | Base URL of the Dialogs backend, for example https://dialogs.enablex.io. |
rootPath | String | No | Optional URL path prefix appended to host. Default ''. |
callingEnabled | bool | No | Enables the audio and video call buttons in the input bar. Default false. See Call buttons. |
EnxChatTheme
const EnxChatTheme({
Color primaryColor = const Color(0xFF075E54),
Color userBubbleColor = const Color(0xFFDCF8C6),
Color botBubbleColor = Colors.white,
Color backgroundColor = const Color(0xFFECE5DD),
Color userAvatarColor = const Color(0xFF2196F3),
Color botAvatarColor = const Color(0xFF4CAF50),
bool useMobileClassicLayout = false,
})
| Field | Default | Applies to |
|---|---|---|
primaryColor | #075E54 (dark green) | App bar, send button, accents |
userBubbleColor | #DCF8C6 (light green) | User message bubbles |
botBubbleColor | #FFFFFF | Bot message bubbles |
backgroundColor | #ECE5DD (off-white) | Chat area background |
userAvatarColor | #2196F3 (blue) | User avatar |
botAvatarColor | #4CAF50 (green) | Bot avatar |
useMobileClassicLayout | false | Switches to a compact layout for small screens |
EnxChatTheme.mobileClassic is a static preset: the WhatsApp-style green theme with the compact layout turned on.
For EnxChatController, EnxMessage, the sub-models and the enums, see the Flutter Chatbot SDK API reference.
Layered Architecture
Your app talks only to the widgets and, optionally, the controller. Everything below that is inside the plugin: the controller owns a JavaScript bridge, and the bridge drives a hidden WebView that runs the chat engine and holds the socket connection. Calls use a second, separate WebView.
| Layer | Responsibility |
|---|---|
| UI layer | EnxChatScreen and EnxChatWidget, built from EnxChatList (scrolling list with date separators), EnxMessageCell (one renderer per message type), EnxInputBar (text, attachments, call buttons), EnxTypingBubble and EnxVideoCallOverlay. |
| Controller | EnxChatController holds all chat state (messages, status, typing, bot info, call state), exposes streams and callbacks, and provides the send, reset and reconnect methods. |
| Bridge | EnxWebViewBridge loads assets/chat/chat.html into a hidden 1×1 WebView, sends it the bot config, receives its events over a JavaScript channel named EnxChannel and sends it commands. |
| Hidden chat WebView | Runs the EnableX chat runtime and the Socket.IO connection to the Dialogs server. File uploads go from here to the EnableX CDN over HTTPS. |
| Call overlay | EnxVideoCallOverlay is a separate InAppWebView that loads the call page. It has no access to the chat WebView. |
Sequence Diagrams
Click any diagram to open it at full size.
Chat startup & messaging
From creating the controller, through the WebView handshake and connection, to sending a message and receiving the bot's reply.
Video call overlay
From the bot's call-start message to the overlay closing.
The connection state machine (EnxConnectionStatus) is shown on the Flutter Chatbot SDK page.
Feature Support (v1.0.0)
| Feature | Supported | Notes |
|---|---|---|
| Full-screen and embeddable chat | Yes | EnxChatScreen (with app bar) and EnxChatWidget; bot name and avatar come from the bot's metadata. |
| Bring-your-own controller | Yes | .withController on both widgets; works with Provider, Riverpod, BLoC, GetX or setState. |
| Theme colours | Yes | EnxChatTheme colour tokens and the mobileClassic preset. |
| Text, action buttons, suggestion chips | Yes | Single- and multi-select chips. |
| Image, video and file cards | Yes | Image caching, video thumbnails with play overlay. |
| Sending attachments | Yes | Camera, gallery and document picker; MIME type detected automatically. |
| Typing indicator | Yes | Animated three-dot bubble. |
| System / handover messages | Yes | Centred status messages. |
| In-app video call overlay | Yes | Opens automatically on the bot's call-start message (iFrameUrl); closes on call-stop. |
| Click-to-call bots | Yes | Call-only interface when botInfo.clickToCall is "audio" or "video". |
| Call buttons in the input bar | Yes | Report taps through onAudioCall / onVideoCall; your app handles the call. |
| Conversation reset | Yes | EnxChatController.resetConversation(). |
| Native (token-based) calls | No | Calls always run from an iFrameUrl in the overlay WebView. |
| Calendar date picker | No | calendar messages render as text in v1.0.0; a date picker is planned. |
| Structural UI customisation | No | Only colour tokens and the compact layout switch. |
| Offline message queue | No | Messages sent while disconnected are lost; watch the connection status and prompt the user to retry. |
| Web and desktop | No | iOS and Android only. For web, use the Web Chatbot SDK. |
Known Limitations
- iOS and Android only — no web or desktop targets.
flutter_inappwebviewandpermission_handlermust be declared directly in your app'spubspec.yaml.- Calls are browser calls only; there is no native call path.
- Call buttons report taps to your app but don't open the in-app call overlay.
- The call overlay opens only when the bot sends a call-start message or a click-to-call configuration.
calendarmessages render as text in v1.0.0.- No offline queue — messages sent while disconnected are not retried.
- Requires network access at startup, and Android System WebView 67 or later.
Troubleshooting
Chat shows a blank screen or the spinner never stops
- Check that
botIdandhostare correct. - Confirm the device can reach
host. - Add an
onErrorcallback and look forbridge_errororsocket_error.
MissingPluginException for flutter_inappwebview
- Add
flutter_inappwebview: ^6.1.5(andpermission_handler) to your app'spubspec.yaml. - Run
flutter pub getand do a full rebuild — hot reload does not pick up new plugins.
Video call overlay is black
- Confirm the
iFrameUrlis HTTPS. - Confirm the user granted camera and microphone access, and that
NSCameraUsageDescriptionandNSMicrophoneUsageDescriptionare inInfo.plist. - During development against a non-HTTPS server on iOS, add an
NSAppTransportSecurityexception.
Call buttons don't appear, or nothing happens when tapped
- Set both
callingEnabled: trueonEnxBotConfigandshowCallingOptions: trueon the widget. - Provide
onAudioCall/onVideoCall— the buttons only report taps; see Call buttons.
File upload fails on iOS
- Add all the photo and camera usage descriptions to
Info.plist(see iOS permissions).
Images or videos don't play inline on Android
- Check that
minSdkVersionis at least 21 and that Android System WebView is up to date. The UI Kit configures the WebView for inline playback automatically.
FAQ
Is the UI Kit a different package from the Flutter Chatbot SDK?
No. Both use dialogs_chatbot_flutter. Use the widgets on this page for a ready-made chat; use EnxChatController on its own (see the SDK page) to build your own interface.
Do I need to open the call screen myself?
No. When the bot sends a call-start message, the UI Kit opens the overlay itself and closes it when the call ends. You only need the permissions in place. See How a call runs.
Why doesn't tapping the video call button open a call?
In v1.0.0 the call buttons hand control to your app through onAudioCall and onVideoCall. The in-app overlay is opened only by the bot. See Call buttons.
Can calls run natively instead of in a WebView?
Not in the Flutter UI Kit — calls always load an iFrameUrl in the overlay WebView. If you need a native call, start it from onVideoCall with a calling SDK of your choice.
How much can I change the look?
The colours in EnxChatTheme and the compact layout switch. For a fully custom interface, build your own widgets on top of EnxChatController.