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),
);
}
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: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * .8,
),
margin: isSender
? stateTick
? EdgeInsets.fromLTRB(7, 7, 14, 7)
: EdgeInsets.fromLTRB(7, 7, 17, 7)
: EdgeInsets.fromLTRB(17, 7, 7, 7),
child: Stack(
children: <Widget>[
Padding(
padding: stateTick
? EdgeInsets.only(right: 20)
: EdgeInsets.symmetric(vertical: 0, horizontal: 0),
child: Text(
text,
style: textStyle,
textAlign: TextAlign.left,
),
),
stateIcon != null && stateTick
? Positioned(
bottom: 0,
right: 0,
child: stateIcon,
)
: SizedBox(
width: 1,
),
],
),
),
),
),
);
}