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 audioMessageBuilder(AudioMessage, {required int messageWidth})?, Widget avatarBuilder(User author)?, 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, bool dateIsUtc = false, String? dateLocale, bool? disableImageGallery, EmojiEnlargementBehavior emojiEnlargementBehavior = EmojiEnlargementBehavior.multi, Widget? emptyState, Widget fileMessageBuilder(FileMessage, {required int messageWidth})?, int groupMessagesThreshold = 60000, bool hideBackgroundOnEmojiMessages = true, ImageGalleryOptions imageGalleryOptions = const ImageGalleryOptions(maxScale: PhotoViewComputedScale.covered, minScale: PhotoViewComputedScale.contained), Map<String, String>? imageHeaders, Widget imageMessageBuilder(ImageMessage, {required int messageWidth})?, ImageProvider<Object> imageProviderBuilder({required Conditional conditional, required Map<String, String>? imageHeaders, required String uri})?, InputOptions inputOptions = const InputOptions(), bool? isAttachmentUploading, bool? isLastPage, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, ChatL10n l10n = const ChatL10nEn(), Widget? listBottomWidget, required List<Message> messages, Widget nameBuilder(User)?, VoidCallback? onAttachmentPressed, void onAvatarTap(User)?, VoidCallback? 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), AutoScrollController? scrollController, ScrollPhysics? scrollPhysics, ScrollToUnreadOptions scrollToUnreadOptions = const ScrollToUnreadOptions(), bool showUserAvatars = false, bool showUserNames = false, Widget systemMessageBuilder(SystemMessage)?, Widget textMessageBuilder(TextMessage, {required int messageWidth, required bool showName})?, TextMessageOptions textMessageOptions = const TextMessageOptions(), ChatTheme theme = const DefaultChatTheme(), DateFormat? timeFormat, TypingIndicatorOptions typingIndicatorOptions = const TypingIndicatorOptions(), bool usePreviewData = true, required User user, String? userAgent, bool? useTopSafeAreaInset, Widget videoMessageBuilder(VideoMessage, {required int messageWidth})?, Widget slidableMessageBuilder(Message, Widget msgWidget)?, bool isLeftStatus = false, double messageWidthRatio = 0.72})
Creates a chat widget.
const

Properties

audioMessageBuilder → (Widget Function(AudioMessage, {required int messageWidth})?)
See Message.audioMessageBuilder.
final
avatarBuilder → (Widget Function(User author)?)
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. If you're looking for the bottom widget added to the chat list, see listBottomWidget instead.
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
dateIsUtc bool
Use utc time to convert message milliseconds to date.
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
imageGalleryOptions ImageGalleryOptions
See ImageGallery.options.
final
imageHeaders Map<String, String>?
Headers passed to all network images used in the chat.
final
imageMessageBuilder → (Widget Function(ImageMessage, {required int messageWidth})?)
See Message.imageMessageBuilder.
final
imageProviderBuilder → (ImageProvider<Object> Function({required Conditional conditional, required Map<String, String>? imageHeaders, required String uri})?)
This feature allows you to use a custom image provider. This is useful if you want to manage image loading yourself, or if you need to cache images. You can also use the cached_network_image feature, but when it comes to caching, you might want to decide on a per-message basis. Plus, by using this provider, you can choose whether or not to send specific headers based on the URL.
final
inputOptions InputOptions
See Input.options.
final
isAttachmentUploading bool?
See Input.isAttachmentUploading.
final
isLastPage bool?
See ChatList.isLastPage.
final
isLeftStatus bool
See Message.isLeftStatus. If true, status will be shown on the left side of the message. If false, status will be shown on the right side of the message. Default value is false.
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
listBottomWidget Widget?
See ChatList.bottomWidget. For a custom chat input use customBottomWidget instead.
final
messages List<Message>
List of types.Message to render in the chat widget.
final
messageWidthRatio double
Width ratio for message bubble.
final
nameBuilder → (Widget Function(User)?)
See Message.nameBuilder.
final
onAttachmentPressed VoidCallback?
See Input.onAttachmentPressed.
final
onAvatarTap → (void Function(User)?)
See Message.onAvatarTap.
final
onBackgroundTap VoidCallback?
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
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController → AutoScrollController?
See ChatList.scrollController. If provided, you cannot use the scroll to message functionality.
final
scrollPhysics ScrollPhysics?
See ChatList.scrollPhysics.
final
scrollToUnreadOptions ScrollToUnreadOptions
Controls if and how the chat should scroll to the newest unread message.
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
slidableMessageBuilder → (Widget Function(Message, Widget msgWidget)?)
See Message.slidableMessageBuilder.
final
systemMessageBuilder → (Widget Function(SystemMessage)?)
Builds a system message outside of any bubble.
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
typingIndicatorOptions TypingIndicatorOptions
Used to show typing users with indicator. See TypingIndicatorOptions.
final
usePreviewData bool
See Message.usePreviewData.
final
user → User
See InheritedUser.user.
final
userAgent String?
See Message.userAgent.
final
useTopSafeAreaInset bool?
See ChatList.useTopSafeAreaInset.
final
videoMessageBuilder → (Widget Function(VideoMessage, {required int messageWidth})?)
See Message.videoMessageBuilder.
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}) 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