LMChatAIButton
File location
chatbot_ai_button.dart
LMChatAIButton
is a customizable button widget used within the chat interface to allow for direct initialization of the AI chatbot. It can be used as a FloatingActionButton
or as a regular button. It supports icons, text, and state management for active and inactive modes.
Properties
Property | Type | Required | Description |
---|---|---|---|
text | LMChatText? | No | The text widget to be displayed on the button |
icon | LMChatIcon? | No | The icon widget to be displayed on the button |
style | LMChatAIButtonStyle? | No | Style configuration for customizing the button's appearance |
props | LMChatAIButtonProps? | No | Configuration properties for AI chatbot initialization, including authentication and user information |
onTap | VoidCallback? | No | Callback function triggered when the button is tapped |
Styling
LMChatButtonStyle
File location
chatbot_ai_button.dart
LMChatAIButtonStyle
defines the visual appearance of the button, including text, colors, size, and icon placement.
Property | Type | Required | Default | Description |
---|---|---|---|---|
text | String? | No | 'AI Bot' | The text to be displayed on the button |
textSize | double? | No | 14 | The size of the button text in logical pixels |
textColor | Color? | No | Color(0xFFFFFFFF) | The color of the button text |
backgroundColor | Color? | No | Color(0xFF020D42) | The background color of the button |
borderRadius | double? | No | 28 | The border radius of the button in logical pixels |
icon | IconData? | No | null | The icon to be displayed on the button |
iconPlacement | LMChatIconButtonPlacement | No | LMChatIconButtonPlacement.start | The placement of the icon relative to the text |
You can use the LMChatAIButtonStyle.basic()
method to create a basic style with default values.
Note: These properties are only a subset. More can be found inside the style class.
Props
The LMChatAIButton
accepts the following properties through the LMChatAIButtonProps
class:
Prop | Type | Required | Description |
---|---|---|---|
apiKey | String | Required* | The API key used for authentication when not using token-based security. Required when using the non-token based authentication method. |
uuid | String | Required* | The unique identifier for the user. Required when using the non-token based authentication method. |
userName | String | Required* | The display name of the user. Required when using the non-token based authentication method. |
imageUrl | String | Optional | The URL of the user's profile image. Used for user profile customization. |
isGuest | bool | Optional | Indicates whether the user is a guest user. Defaults to false if not provided. |
accessToken | String | Required** | The access token for token-based security authentication. Required when using the token-based authentication method. |
refreshToken | String | Required** | The refresh token for token-based security authentication. Required when using the token-based authentication method. |
* Required for client-side authentication ** Required for server-side authentication
Authentication Methods
The LMChatAIButton
supports two authentication methods:
Client-Side Authentication
- Requires:
apiKey
,uuid
, anduserName
- Optional:
imageUrl
,isGuest
- Requires:
Server-Side Authentication
- Requires:
accessToken
andrefreshToken
- Requires:
Example Usage
// Example with server-side authentication
final chatButton = LMChatAIButton(
text: LMChatText('Chat with AI'),
icon: LMChatIcon(Icons.chat),
style: LMChatAIButtonStyle.basic(),
props: LMChatAIButtonProps(
accessToken: 'your-access-token',
refreshToken: 'your-refresh-token',
),
);
// Example with client-side authentication
final apiKeyChatButton = LMChatAIButton(
text: LMChatText('Chat with AI'),
icon: LMChatIcon(Icons.chat),
style: LMChatAIButtonStyle.basic(),
props: LMChatAIButtonProps(
apiKey: 'your-api-key',
uuid: 'user-unique-id',
userName: 'John Doe',
),
onTap: () => print('Button tapped'),
);