build method
chat bubble builder method
Implementation
@override
Widget build(BuildContext context) {
IconData? statusIcon;
Color statusIconColor = const Color(0xFF97AD8E);
if (seen) {
statusIcon = Icons.done_all;
statusIconColor = const Color(0xFF92DEDA);
} else if (delivered) {
statusIcon = Icons.done_all;
} else if (sent) {
statusIcon = Icons.done;
}
final Color forwardedColor =
(textStyle.color ?? Colors.black87).withValues(alpha: 0.6);
return Row(
children: <Widget>[
isSender
? Expanded(
child: SizedBox(
width: 5,
),
)
: leading ?? Container(),
Container(
color: Colors.transparent,
constraints: constraints ??
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .8),
margin: margin,
padding: padding,
child: GestureDetector(
onTap: onTap,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
child: Container(
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(bubbleRadius),
topRight: Radius.circular(bubbleRadius),
bottomLeft: Radius.circular(tail
? isSender
? bubbleRadius
: 0
: defaultBubbleRadius),
bottomRight: Radius.circular(tail
? isSender
? 0
: bubbleRadius
: defaultBubbleRadius),
),
),
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isForwarded)
BubbleForwardedHeader(color: forwardedColor),
TimestampedChatMessage(
text: text,
textStyle: textStyle,
timestamp: timestamp,
isEdited: isEdited,
statusIcon: statusIcon,
statusIconColor: statusIconColor,
),
],
),
),
),
),
),
if (isSender && trailing != null) SizedBox.shrink(),
],
);
}