build method

  1. @override
Widget build(
  1. BuildContext context
)
override

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 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
              ? 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),
              Padding(
                padding: const EdgeInsets.only(left: 4, right: 4),
                child: TimestampedChatMessage(
                  text: text,
                  textStyle: textStyle,
                  timestamp: timestamp,
                  isEdited: isEdited,
                  statusIcon: statusIcon,
                  statusIconColor: statusIconColor,
                ),
              ),
            ],
          ),
        ),
      ),
    ),
  );
}