Conversation List
Scrollable list of past conversations with search and selection. Displays conversation titles, previews, timestamps, and supports swipe-to-delete.
Installation
$
flai add conversation_list
Import
import 'package:my_app/flai/components/conversation_list/conversation_list.dart';
Preview
Preview
REST API in Dart
You: How do I add middleware?
2m
Flutter state management
Riverpod is recommended for...
1h
Database design
For your schema, I suggest...
1d
Usage
FlaiConversationList(
conversations: conversations,
selectedId: currentConversationId,
onSelect: (conversation) {
setState(() {
currentConversationId = conversation.id;
});
loadConversation(conversation);
},
onDelete: (conversation) {
deleteConversation(conversation.id);
},
onNewChat: () {
createNewConversation();
},
)
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| conversations | List<Conversation> | required | List of conversations to display. |
| selectedId | String? | null | ID of the currently selected conversation. |
| onSelect | Function(Conversation) | required | Called when a conversation is tapped. |
| onDelete | Function(Conversation)? | null | Called when swipe-to-delete is confirmed. |
| onNewChat | VoidCallback? | null | Called when the "New Chat" button is tapped. |
| showSearch | bool | true | Whether to show the search bar. |
Conversation Model
class Conversation {
final String id;
final String title;
final String? preview; // Last message preview text
final DateTime updatedAt;
final String? modelId; // Associated model ID
}
Features
- Search — Filter conversations by title or preview text
- Selection — Highlighted background for the active conversation
- Swipe-to-delete — Dismissible with destructive action
- New chat button — Optional floating or header button
- Grouped by date — Today, Yesterday, Previous 7 Days, Older
- Empty state — Helpful message when no conversations exist