ChatScreen class

A screen for displaying and sending chat messages between two users.

Supports custom message input, message bubble, media upload, and message selection callbacks.

Inheritance
Available extensions

Constructors

ChatScreen.new({required String senderId, required String receiverId, DecorationImage? backgroundImage, PreferredSizeWidget? appBar, Color? backgroundColor, bool enableDivider = true, bool enableDeleteMessage = true, Widget sendMessageBuilder(BuildContext context, {void onTypingMessage(String text)?, required void sendMediaMessage(String mediaPath, MessageType type), required void sendMessage(String txt)})?, Widget messageBubbleBuilder({required bool isMe, required Message message})?, Future<String> mediaUploaderFunction(String mediaPath)?, int? intialChatLimit, dynamic getLastSeen(DateTime lastSeen)?, dynamic onDeleteMessage()?, Widget dividerBuilder(String label)?, bool enableTypingStatus = false, Widget typingIdicationBuilder()?, Key? key, void onMessageSelected({required void deselectAll(), required List<Message> messages})?, EdgeInsets? listPadding})
Creates a ChatScreen widget. deleteMessage feature is enabled by default.
const

Properties

appBar PreferredSizeWidget?
Optional app bar for the chat screen. If not provided, no app bar will be displayed. You can use this to add a custom app bar with title, actions, etc. If you want to use the default app bar, you can pass an empty PreferredSizeWidget.
final
backgroundColor Color?
Color for the background of the chat screen.
final
backgroundImage DecorationImage?
Optional background image for the chat screen. If provided, this image will be displayed as the background of the chat screen.
final
dividerBuilder Widget Function(String label)?
Divide chat date-vise, label will be the divided date.
final
enableDeleteMessage bool
Whether to enable the delete message feature.
final
enableDivider bool
Enable/disable date-vise divider. Default value will be true
final
enableTypingStatus bool
Whether to enable typing status updates. If true, typing status will be sent when the user types a message.
final
getLastSeen → dynamic Function(DateTime lastSeen)?
Optional callback to provide the last seen time of the receiver.
final
hashCode int
The hash code for this object.
no setterinherited
intialChatLimit int?
The initial number of chat messages to load.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
listPadding EdgeInsets?
The padding to apply around the message list.
final
mediaUploaderFunction Future<String> Function(String mediaPath)?
Optional function for uploading media files.
final
messageBubbleBuilder Widget Function({required bool isMe, required Message message})?
Optional builder for customizing the message bubble widget.
final
onDeleteMessage → dynamic Function()?
Optional callback for when a message is deleted.
final
onMessageSelected → void Function({required void deselectAll(), required List<Message> messages})?
Optional callback for when messages are selected.
final
receiverId String
The ID of the user receiving messages.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
senderId String
The ID of the user sending messages.
final
sendMessageBuilder Widget Function(BuildContext context, {void onTypingMessage(String text)?, required void sendMediaMessage(String mediaPath, MessageType type), required void sendMessage(String txt)})?
Optional builder for customizing the message input widget. This builder provides a context and functions to send text and media messages, and optionally handle typing status. If not provided, a default MessageInput widget will be used. This builder can also handle media messages. onTypingMessage have to call when the user types a message. It can be null if typing status is not needed. call onTypingMessage function in TextField's onChange.
final
typingIdicationBuilder Widget Function()?
Optional function to handle typing status updates. This function should be called when the user types a message.
final

Methods

box({double? height, double? width, Alignment alignment = Alignment.centerLeft}) Widget

Available on Widget, provided by the WrapIt extension

Wraps the widget in a Container with optional height, width, and alignment.
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<ChatScreen>
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