AI Agent Component Spec
AI Agent Component Spec
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
Complete Example
- Dart
Next Steps
Custom Text Formatter
Build custom inline text patterns.
Message List
Render real-time message threads.
All Guides
Browse all feature and formatter guides.
Sample App
Full working sample application on GitHub.