ChatMessage class
Default wrapper widget for a single chat message item.
Handles layout (alignment based on sender), animation (fade, scale, size), padding (adjusting for grouped messages), and tap/long-press gestures. It arranges the core message child with optional surrounding widgets (leadingWidget, trailingWidget, topWidget, bottomWidget, headerWidget).
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- ChatMessage
Constructors
-
ChatMessage.new({Key? key, required Message message, required int index, required Animation<
double> animation, required Widget child, Widget? leadingWidget, Widget? trailingWidget, Widget? topWidget, Widget? bottomWidget, Widget? headerWidget, Alignment sentMessageScaleAnimationAlignment = Alignment.centerRight, Alignment receivedMessageScaleAnimationAlignment = Alignment.centerLeft, AlignmentGeometry sentMessageAlignment = AlignmentDirectional.centerEnd, AlignmentGeometry receivedMessageAlignment = AlignmentDirectional.centerStart, CrossAxisAlignment sentMessageColumnAlignment = CrossAxisAlignment.end, CrossAxisAlignment receivedMessageColumnAlignment = CrossAxisAlignment.start, CrossAxisAlignment sentMessageRowAlignment = CrossAxisAlignment.end, CrossAxisAlignment receivedMessageRowAlignment = CrossAxisAlignment.end, Alignment? scaleAnimationAlignment, AlignmentGeometry? alignment, EdgeInsetsGeometry? padding, Duration? paddingChangeAnimationDuration = const Duration(milliseconds: 250), bool? isRemoved, MessageGroupStatus? groupStatus, double? horizontalPadding = 8, double? verticalPadding = 12, double? verticalGroupedPadding = 2}) -
Creates a default chat message wrapper widget.
const
Properties
- alignment → AlignmentGeometry?
-
Overrides the sender-based message container alignment if provided.
final
-
animation
→ Animation<
double> -
Animation provided by the parent SliverAnimatedList.
final
- bottomWidget → Widget?
-
Widget to display below the main message row.
final
- child → Widget
-
The core widget representing the message content (e.g., text bubble, image).
final
- groupStatus → MessageGroupStatus?
-
Status indicating if this message is part of a group (first, middle, last).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- headerWidget → Widget?
-
Widget to display above the entire message structure (including potential topWidget).
final
- horizontalPadding → double?
-
Default horizontal padding for message items.
final
- index → int
-
The index of the message in the list.
final
- isRemoved → bool?
-
Flag indicating if this item is being animated out (removed).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- leadingWidget → Widget?
-
Widget to display to the left/start of the message content.
final
- message → Message
-
The message data being displayed.
final
- padding → EdgeInsetsGeometry?
-
Overrides the default padding calculation if provided.
final
- paddingChangeAnimationDuration → Duration?
-
Duration for the animated padding change (e.g., when grouping status changes).
final
- receivedMessageAlignment → AlignmentGeometry
-
Alignment for the message container for received messages.
final
- receivedMessageColumnAlignment → CrossAxisAlignment
-
Cross-axis alignment for the main column for received messages.
final
- receivedMessageRowAlignment → CrossAxisAlignment
-
Cross-axis alignment for the content row for received messages.
final
- receivedMessageScaleAnimationAlignment → Alignment
-
Alignment for the scale animation origin for received messages.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaleAnimationAlignment → Alignment?
-
Overrides the sender-based scale animation alignment if provided.
final
- sentMessageAlignment → AlignmentGeometry
-
Alignment for the message container for sent messages.
final
- sentMessageColumnAlignment → CrossAxisAlignment
-
Cross-axis alignment for the main column for sent messages.
final
- sentMessageRowAlignment → CrossAxisAlignment
-
Cross-axis alignment for the content row for sent messages.
final
- sentMessageScaleAnimationAlignment → Alignment
-
Alignment for the scale animation origin for sent messages.
final
- topWidget → Widget?
-
Widget to display above the main message row.
final
- trailingWidget → Widget?
-
Widget to display to the right/end of the message content.
final
- verticalGroupedPadding → double?
-
Vertical padding between grouped messages.
final
- verticalPadding → double?
-
Default vertical padding between non-grouped messages.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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