build method
chat bubble builder method
Implementation
@override
Widget build(BuildContext context) {
bool stateTick = false;
Icon? stateIcon;
if (sent) {
stateTick = true;
stateIcon = const Icon(
Icons.done,
size: 18,
color: Color(0xFF97AD8E),
);
}
if (delivered) {
stateTick = true;
stateIcon = const Icon(
Icons.done_all,
size: 18,
color: Color(0xFF97AD8E),
);
}
if (seen) {
stateTick = true;
stateIcon = const Icon(
Icons.done_all,
size: 18,
color: Color(0xFF92DEDA),
);
}
return Align(
alignment: isSender ? Alignment.topRight : Alignment.topLeft,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: CustomPaint(
painter: SpecialChatBubbleThree(
color: color,
alignment: isSender ? Alignment.topRight : Alignment.topLeft,
tail: tail),
child: Container(
constraints: constraints ??
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * .7,
),
margin: isSender
? stateTick
? const EdgeInsets.fromLTRB(7, 7, 14, 7)
: const EdgeInsets.fromLTRB(7, 7, 17, 7)
: const EdgeInsets.fromLTRB(17, 7, 7, 7),
child: Stack(
children: <Widget>[
Padding(
padding: stateTick
? const EdgeInsets.only(left: 4, right: 20)
: const EdgeInsets.only(left: 4, right: 4),
child: Text(
text,
style: textStyle,
textAlign: TextAlign.left,
),
),
stateIcon != null && stateTick
? Positioned(
bottom: 0,
right: 0,
child: stateIcon,
)
: const SizedBox(
width: 1,
),
],
),
),
),
),
);
}