AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | cometchat_chat_uikit |
| Key class | CometChatUrlFormatter (extends CometChatTextFormatter) |
| Required setup | CometChatUIKit.init(uiKitSettings: uiKitSettings) then CometChatUIKit.login("UID") |
| Purpose | Auto-detects URLs in text messages and converts them to clickable links |
| Sample app | GitHub |
| Related | Custom Text Formatter | All Guides |
CometChatUrlFormatter extends CometChatTextFormatter to detect URLs in text messages and render them as clickable links.

Overview
The URL formatter is included by default in the Flutter UI Kit. It automatically:- Detects URLs in message text using regex patterns
- Styles URLs with underline and link color
- Opens URLs in the browser when tapped
Default Behavior
TheCometChatUrlFormatter is automatically applied to messages. URLs are:
- Styled with underline decoration
- Colored based on bubble alignment (white for outgoing, info color for incoming)
- Clickable - tapping opens the URL in the default browser
Usage
Basic Usage (Default)
The URL formatter is included by default. No additional setup required.- Dart
Custom URL Formatter
Create a custom URL formatter with your own styling and behavior.- Dart
Apply Custom Formatter
- Dart
Customization
Styling Links
OverridegetMessageBubbleTextStyle to customize link appearance:
- Dart
Custom URL Pattern
Use a custom regex pattern to match specific URL formats:- Dart
Handle URL Clicks
OverridegetAttributedText to add custom click handling:
- Dart
Properties
| Property | Type | Description |
|---|---|---|
pattern | RegExp? | Regex pattern to match URLs |
messageBubbleTextStyle | Function? | Custom style for URL text in bubbles |
onSearch | Function? | Callback when URL is detected |
showLoadingIndicator | bool? | Show loading indicator during processing |
Complete Example
- Dart