ConversationList

class ConversationList

A list of conversations that the current user is a part of.

It makes available a callback, onSelectConversation, that gets triggered when the user clicks on one of the conversations.

In most cases, you will just want this handler to navigate to a screen that contains a ChatBox. showing the conversation that has just been selected.

Available Methods

ConstructorCreates a ConversationList UI.

Constructor

1const ConversationList({
2 Key? key,
3 required Session session,
4 bool enableZoom = false,
5 bool? showFeedHeader,
6 String? theme,
7 ThemeOptions? themeOptions,
8 BaseConversationPredicate? feedFilter,
9 SelectConversationHandler? onSelectConversation,
10 LoadingStateHandler? onLoadingStateChanged,
11});

Creates a ConversationList UI.

NOTE: All the parameters passed to the constructor are also available as read-only properties of the constructed object.

Parameters

key
(optional)Key?

A Key is an identifier for Flutter Widgets.

session
Session

The TalkJS Session object to use for this ConversationList.

enableZoom
(optional)bool

Controls whether the user can pinch to zoom the UI. Defaults to false.

showFeedHeader
bool?

Controls if the feed header containing the toggle to enable desktop notifications is shown. Defaults to true.

theme
(optional)String?

Overrides the theme used for this chat UI. Overriding the theme only works with themes created in the Theme Editor.

If you omit both the theme and themeOptions properties, the UI uses the theme that is selected in the current user's role.

If both the theme and themeOptions properties are specified, the themeOptions property takes precedence.

themeOptions
(optional)ThemeOptions?

Overrides the theme used for this chat UI. Overriding the theme only works with themes created in the Theme Editor.

You can use the themeOptions property instead of theme to pass variables to your theme.

If you omit both the theme and themeOptions properties, the UI uses the theme that is selected in the current user's role.

If both the theme and themeOptions properties are specified, the themeOptions property takes precedence.

feedFilter
(optional)BaseConversationPredicate?

Controls which conversations are shown in the conversation feed.

Lets you filter conversations in the conversation list, depending on access level, custom conversation attributes or message read status.

See ConversationPredicate and CompoundConversationPredicate for all available options.

Example

1// only show conversations with unread messages
2feedFilter: ConversationPredicate(
3 hasUnreadMessages: true,
4),

Example

1// only show conversations with unread messages OR whose subject equals "Pink shoes"
2feedFilter: CompoundConversationPredicate.any([
3 ConversationPredicate(
4 hasUnreadMessages: true,
5 ),
6 ConversationPredicate(
7 subject: FieldPredicate.equals('Pink shoes'),
8 ),
9]),
onSelectConversation
SelectConversationHandler?

Triggers when a user clicks a conversation in the feed

onLoadingStateChanged
(optional)LoadingStateHandler?

Triggers when the loading state of the ConversationList changes.

The Getting Started guide has an example on how to use the onLoadingStateChanged callback to show a loading indicator while the ChatBox is loading.


Event Handlers

SelectConversationHandler

1typedef SelectConversationHandler = void Function(SelectConversationEvent event);

See SelectConversationEvent for the callback parameter.

LoadingStateHandler

1typedef LoadingStateHandler = void Function(LoadingState state);

Notifies when the loading state of the ChatBox changes.

The LoadingState can be either loading or loaded, and it can be useful for showing a placeholder widget while the ChatBox is loading.

The Getting Started guide has an example on how to use the onLoadingStateChanged callback to show a loading indicator while the ChatBox is loading.