MessagePanel class
MessagePanel
provides a UI for displaying and sending messages in an event or chat context.
It includes group and direct messaging capabilities, allowing the user to reply to messages
or send group messages, depending on configuration.
Parameters:
MessagePanelOptions
options
: Configures the message panel, including settings for sending messages, message display, and message reply functionality.messages
: List ofMessage
objects to display.type
: String representing the message type ('direct'
or'group'
).onSendMessagePress
: Callback for sending a message.backgroundColor
: Background color for the panel.focusedInput
: Whether the input field should be focused initially.eventType
,member
,islevel
: Event information and user role level.directMessageDetails
: Details of the user to whom a direct message is addressed.socket
: Socket instance for real-time communication.showAlert
: Optional callback to display alerts.
Main Components:
MessageBubble
: Represents an individual message in the list, showing sender details, timestamp, and message content. Includes a reply button for certain roles.MessageInput
: Provides an input field for typing messages, with an optional reply mode.
Key Functions:
_handleSendButton
: Validates and sends the message. If a message reply is required, it ensures a target message is selected._focusInputAndSetReplyInfo
and_clearReplyInfoAndInput
: Manage reply information, focusing the input field on specific messages or clearing it.
Example Usage:
MessagePanel(
options: MessagePanelOptions(
messages: myMessages,
type: 'group',
username: 'User123',
onSendMessagePress: (SendMessageOptions options) {
// Define your send message logic here
},
member: 'User123',
islevel: '2',
roomName: 'MainRoom',
socket: mySocket,
chatSetting: 'default',
coHost: 'CoHostName',
coHostResponsibility: [CoHostResponsibility(name: 'message', value: true)],
eventType: EventType.chat,
messagesLength: myMessages.length,
),
),
Message Components:
- MessageBubble: Displays individual messages, showing sender details and the option to reply for certain users.
- MessageInput: Input field for composing messages. It automatically sets the placeholder text based on whether it's a group or direct message, and whether a reply is active.
Dependencies:
Requires the following imports:
import 'package:flutter/material.dart';
import '../../methods/message_methods/send_message.dart' show sendMessage;
import '../../types/types.dart' show CoHostResponsibility, EventType, Message, Participant;
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MessagePanel
Constructors
- MessagePanel({Key? key, required MessagePanelOptions options})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- options → MessagePanelOptions
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _MessagePanelState -
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