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: SpecialChatBubbleOne(color: color, alignment: isSender ? Alignment.topRight : Alignment.topLeft, tail: tail),
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
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(right: 20) : const EdgeInsets.symmetric(vertical: 0, horizontal: 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
text,
style: textStyle,
textAlign: isSender ? TextAlign.left : TextAlign.left,
),
const SizedBox(height: 5),
Text(
date,
style: textStyle.copyWith(
fontSize: 11,
color: Colors.grey.shade800,
),
textAlign: isSender ? TextAlign.left : TextAlign.left,
),
],
),
),
stateIcon != null && stateTick
? Positioned(
bottom: 0,
right: 0,
child: stateIcon,
)
: const SizedBox(
width: 1,
),
],
),
),
),
),
);
}