Chat class

Entry widget, represents the complete chat. If you wrap it in SafeArea and it should be full screen, set SafeArea's bottom to false.

Inheritance

Constructors

Chat({Key? key, Widget avatarBuilder(String userId)?, Widget bubbleBuilder(Widget child, {required Message message, required bool nextMessageInGroup})?, BubbleRtlAlignment? bubbleRtlAlignment = BubbleRtlAlignment.right, Widget? customBottomWidget, String customDateHeaderText(DateTime)?, Widget customMessageBuilder(CustomMessage, {required int messageWidth})?, Widget customStatusBuilder(Message message, {required BuildContext context})?, DateFormat? dateFormat, Widget dateHeaderBuilder(DateHeader)?, int dateHeaderThreshold = 900000, String? dateLocale, bool? disableImageGallery, EmojiEnlargementBehavior emojiEnlargementBehavior = EmojiEnlargementBehavior.multi, Widget? emptyState, Widget fileMessageBuilder(FileMessage, {required int messageWidth})?, int groupMessagesThreshold = 60000, bool hideBackgroundOnEmojiMessages = true, Widget imageMessageBuilder(ImageMessage, {required int messageWidth})?, bool? isAttachmentUploading, bool? isLastPage, bool isTextMessageTextSelectable = true, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, ChatL10n l10n = const ChatL10nEn(), required List<Message> messages, Widget nameBuilder(String userId)?, void onAttachmentPressed()?, void onAvatarTap(User)?, void onBackgroundTap()?, Future<void> onEndReached()?, double? onEndReachedThreshold, void onMessageDoubleTap(BuildContext context, Message)?, void onMessageLongPress(BuildContext context, Message)?, void onMessageStatusLongPress(BuildContext context, Message)?, void onMessageStatusTap(BuildContext context, Message)?, void onMessageTap(BuildContext context, Message)?, void onMessageVisibilityChanged(Message, bool visible)?, void onPreviewDataFetched(TextMessage, PreviewData)?, required void onSendPressed(PartialText), void onTextChanged(String)?, void onTextFieldTap()?, PreviewTapOptions previewTapOptions = const PreviewTapOptions(), ScrollController? scrollController, ScrollPhysics? scrollPhysics, SendButtonVisibilityMode sendButtonVisibilityMode = SendButtonVisibilityMode.editing, bool showUserAvatars = false, bool showUserNames = false, TextEditingController? textEditingController, Widget textMessageBuilder(TextMessage, {required int messageWidth, required bool showName})?, TextMessageOptions textMessageOptions = const TextMessageOptions(), ChatTheme theme = const DefaultChatTheme(), DateFormat? timeFormat, bool usePreviewData = true, required User user, String? userAgent})
Creates a chat widget.
const

Properties

avatarBuilder Widget Function(String userId)?
See Message.avatarBuilder.
final
bubbleBuilder Widget Function(Widget child, {required Message message, required bool nextMessageInGroup})?
See Message.bubbleBuilder.
final
bubbleRtlAlignment BubbleRtlAlignment?
See Message.bubbleRtlAlignment.
final
customBottomWidget Widget?
Allows you to replace the default Input widget e.g. if you want to create a channel view.
final
customDateHeaderText String Function(DateTime)?
If dateFormat, dateLocale and/or timeFormat is not enough to customize date headers in your case, use this to return an arbitrary string based on a DateTime of a particular message. Can be helpful to return "Today" if DateTime is today. IMPORTANT: this will replace all default date headers, so you must handle all cases yourself, like for example today, yesterday and before. Or you can just return the same date header for any message.
final
customMessageBuilder Widget Function(CustomMessage, {required int messageWidth})?
See Message.customMessageBuilder.
final
customStatusBuilder Widget Function(Message message, {required BuildContext context})?
See Message.customStatusBuilder.
final
dateFormat → DateFormat?
Allows you to customize the date format. IMPORTANT: only for the date, do not return time here. See timeFormat to customize the time format. dateLocale will be ignored if you use this, so if you want a localized date make sure you initialize your DateFormat with a locale. See customDateHeaderText for more customization.
final
dateHeaderBuilder Widget Function(DateHeader)?
Custom date header builder gives ability to customize date header widget.
final
dateHeaderThreshold int
Time (in ms) between two messages when we will render a date header. Default value is 15 minutes, 900000 ms. When time between two messages is higher than this threshold, date header will be rendered. Also, not related to this value, date header will be rendered on every new day.
final
dateLocale String?
Locale will be passed to the Intl package. Make sure you initialized date formatting in your app before passing any locale here, otherwise an error will be thrown. Also see customDateHeaderText, dateFormat, timeFormat.
final
disableImageGallery bool?
Disable automatic image preview on tap.
final
emojiEnlargementBehavior EmojiEnlargementBehavior
See Message.emojiEnlargementBehavior.
final
emptyState Widget?
Allows you to change what the user sees when there are no messages. emptyChatPlaceholder and emptyChatPlaceholderTextStyle are ignored in this case.
final
fileMessageBuilder Widget Function(FileMessage, {required int messageWidth})?
See Message.fileMessageBuilder.
final
groupMessagesThreshold int
Time (in ms) between two messages when we will visually group them. Default value is 1 minute, 60000 ms. When time between two messages is lower than this threshold, they will be visually grouped.
final
hashCode int
The hash code for this object.
no setterinherited
hideBackgroundOnEmojiMessages bool
See Message.hideBackgroundOnEmojiMessages.
final
imageMessageBuilder Widget Function(ImageMessage, {required int messageWidth})?
See Message.imageMessageBuilder.
final
isAttachmentUploading bool?
See Input.isAttachmentUploading.
final
isLastPage bool?
See ChatList.isLastPage.
final
isTextMessageTextSelectable bool
See Message.isTextMessageTextSelectable.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardDismissBehavior ScrollViewKeyboardDismissBehavior
See ChatList.keyboardDismissBehavior.
final
l10n ChatL10n
Localized copy. Extend ChatL10n class to create your own copy or use existing one, like the default ChatL10nEn. You can customize only certain properties, see more here ChatL10nEn.
final
messages List<Message>
List of types.Message to render in the chat widget.
final
nameBuilder Widget Function(String userId)?
See Message.nameBuilder.
final
onAttachmentPressed → void Function()?
See Input.onAttachmentPressed.
final
onAvatarTap → void Function(User)?
See Message.onAvatarTap.
final
onBackgroundTap → void Function()?
Called when user taps on background.
final
onEndReached Future<void> Function()?
See ChatList.onEndReached.
final
onEndReachedThreshold double?
See ChatList.onEndReachedThreshold.
final
onMessageDoubleTap → void Function(BuildContext context, Message)?
See Message.onMessageDoubleTap.
final
onMessageLongPress → void Function(BuildContext context, Message)?
See Message.onMessageLongPress.
final
onMessageStatusLongPress → void Function(BuildContext context, Message)?
See Message.onMessageStatusLongPress.
final
onMessageStatusTap → void Function(BuildContext context, Message)?
See Message.onMessageStatusTap.
final
onMessageTap → void Function(BuildContext context, Message)?
See Message.onMessageTap.
final
onMessageVisibilityChanged → void Function(Message, bool visible)?
See Message.onMessageVisibilityChanged.
final
onPreviewDataFetched → void Function(TextMessage, PreviewData)?
See Message.onPreviewDataFetched.
final
onSendPressed → void Function(PartialText)
See Input.onSendPressed.
final
onTextChanged → void Function(String)?
See Input.onTextChanged.
final
onTextFieldTap → void Function()?
See Input.onTextFieldTap.
final
previewTapOptions PreviewTapOptions
See Message.previewTapOptions.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
See ChatList.scrollController.
final
scrollPhysics ScrollPhysics?
See ChatList.scrollPhysics.
final
sendButtonVisibilityMode SendButtonVisibilityMode
See Input.sendButtonVisibilityMode.
final
showUserAvatars bool
See Message.showUserAvatars.
final
showUserNames bool
Show user names for received messages. Useful for a group chat. Will be shown only on text messages.
final
textEditingController TextEditingController?
See Input.textEditingController.
final
textMessageBuilder Widget Function(TextMessage, {required int messageWidth, required bool showName})?
See Message.textMessageBuilder.
final
textMessageOptions TextMessageOptions
See Message.textMessageOptions.
final
theme ChatTheme
Chat theme. Extend ChatTheme class to create your own theme or use existing one, like the DefaultChatTheme. You can customize only certain properties, see more here DefaultChatTheme.
final
timeFormat → DateFormat?
Allows you to customize the time format. IMPORTANT: only for the time, do not return date here. See dateFormat to customize the date format. dateLocale will be ignored if you use this, so if you want a localized time make sure you initialize your DateFormat with a locale. See customDateHeaderText for more customization.
final
usePreviewData bool
See Message.usePreviewData.
final
user User
See InheritedUser.user.
final
userAgent String?
See Message.userAgent.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<Chat>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited