build method

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

image 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),
    );
  }

  final bool showStatusArea = stateTick || timestamp != null;

  return Row(
    children: <Widget>[
      isSender
          ? const Expanded(
              child: SizedBox(
                width: 5,
              ),
            )
          : leading ?? Container(),
      Container(
        padding: padding,
        margin: margin,
        constraints: BoxConstraints(
          maxWidth: MediaQuery.of(context).size.width * .5,
          maxHeight: MediaQuery.of(context).size.width * .5,
        ),
        child: GestureDetector(
            onLongPress: onLongPress,
            onTap: onTap ??
                () {
                  Navigator.push(context, MaterialPageRoute(builder: (_) {
                    return _DetailScreen(
                      tag: id,
                      image: image,
                    );
                  }));
                },
            child: Hero(
              tag: id,
              child: Stack(
                children: [
                  Container(
                    decoration: BoxDecoration(
                      color: color,
                      borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(bubbleRadius),
                        topRight: Radius.circular(bubbleRadius),
                        bottomLeft: Radius.circular(tail
                            ? isSender
                                ? bubbleRadius
                                : 0
                            : defaultBubbleRadiusImage),
                        bottomRight: Radius.circular(tail
                            ? isSender
                                ? 0
                                : bubbleRadius
                            : defaultBubbleRadiusImage),
                      ),
                    ),
                    child: Padding(
                      padding: const EdgeInsets.all(4.0),
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(bubbleRadius),
                        child: image,
                      ),
                    ),
                  ),
                  if (isForwarded)
                    Positioned(
                      top: 8,
                      left: 8,
                      child: Container(
                        padding: const EdgeInsets.symmetric(
                            horizontal: 6, vertical: 2),
                        decoration: BoxDecoration(
                          color: Colors.black.withOpacity(0.45),
                          borderRadius: BorderRadius.circular(8),
                        ),
                        child: const BubbleForwardedHeader(
                            color: Colors.white),
                      ),
                    ),
                  if (showStatusArea)
                    Positioned(
                      bottom: 8,
                      right: 8,
                      child: Container(
                        padding: const EdgeInsets.symmetric(
                            horizontal: 4, vertical: 2),
                        decoration: BoxDecoration(
                          color: Colors.black.withOpacity(0.45),
                          borderRadius: BorderRadius.circular(8),
                        ),
                        child: BubbleStatusRow(
                          stateIcon: stateTick ? stateIcon : null,
                          timestamp: timestamp,
                          textColor: Colors.white,
                        ),
                      ),
                    ),
                ],
              ),
            ),
          ),
      ),
      if (isSender && trailing != null) SizedBox.shrink(),
    ],
  );
}