build method
chat bubble builder method
Implementation
@override
Widget build(BuildContext context) {
bool stateTick = false;
Icon? stateIcon;
if (sent) {
stateTick = true;
stateIcon = Icon(
Icons.done,
size: 18,
color: Color(0xFF97AD8E),
);
}
if (delivered) {
stateTick = true;
stateIcon = Icon(
Icons.done_all,
size: 18,
color: Color(0xFF97AD8E),
);
}
if (seen) {
stateTick = true;
stateIcon = Icon(
Icons.done_all,
size: 18,
color: Color(0xFF92DEDA),
);
}
final bool showStatusArea = stateTick || timestamp != null || isEdited;
final Color forwardedColor =
(textStyle.color ?? Colors.black87).withOpacity(0.6);
return Align(
alignment: isSender ? Alignment.topRight : Alignment.topLeft,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: CustomPaint(
painter: _SpecialChatBubbleTwo(
color: color,
alignment: isSender ? Alignment.topRight : Alignment.topLeft,
tail: tail),
child: Container(
constraints: constraints ??
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * .8,
),
margin: isSender
? const EdgeInsets.fromLTRB(7, 7, 14, 7)
: const EdgeInsets.fromLTRB(17, 7, 7, 7),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isForwarded) BubbleForwardedHeader(color: forwardedColor),
Text(
text,
style: textStyle,
textAlign: TextAlign.left,
),
if (showStatusArea)
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.only(top: 2),
child: BubbleStatusRow(
stateIcon: stateTick ? stateIcon : null,
isEdited: isEdited,
timestamp: timestamp,
textColor: textStyle.color ?? Colors.black87,
),
),
),
],
),
),
),
),
);
}