build method

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

chat bubble builder method

Implementation

@override
Widget build(BuildContext context) {
  bool stateTick = false;
  Widget? 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),
    );
  }

  if (timeWidget != null) {
    if (stateIcon != null) {
      stateIcon = Row(children: [
        timeWidget!,
        SizedBox(width: 3),
        stateIcon,
      ]);
    } else {
      stateIcon = timeWidget;
    }
  }

  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: Container(
          constraints: BoxConstraints(
            maxWidth: MediaQuery.of(context).size.width * .7,
          ),
          margin: isSender
              ? stateTick || timeWidget != null
                  ? 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
                    ? timeWidget != null
                        ? EdgeInsets.only(right: 50)
                        : EdgeInsets.only(right: 20)
                    : timeWidget != null
                        ? EdgeInsets.only(right: 30)
                        : EdgeInsets.symmetric(vertical: 0, horizontal: 0),
                child: Column(children: [widget]),
              ),
              stateIcon != null && (stateTick || timeWidget != null)
                  ? Positioned(
                      bottom: 0,
                      right: 0,
                      child: stateIcon,
                    )
                  : SizedBox(
                      width: 1,
                    ),
            ],
          ),
        ),
      ),
    ),
  );
}