bubbleBuilder method

  1. @override
Widget bubbleBuilder(
  1. BuildContext context,
  2. Message message,
  3. MessageRenderContext ctx
)
override

Implementation

@override
Widget bubbleBuilder(BuildContext context, Message message,
    MessageRenderContext ctx) {
  final p = message.payload as VideoPayload;
  return GestureDetector(
    onTap: ctx.onTap,
    child: Stack(
      alignment: Alignment.center,
      children: [
        ClipRRect(
          borderRadius: BorderRadius.circular(10),
          child: p.thumbnailUrl != null
              ? Image.network(
                  p.thumbnailUrl!,
                  width: 240,
                  height: 160,
                  fit: BoxFit.cover,
                  errorBuilder: (_, __, ___) => _videoPlaceholder(),
                )
              : _videoPlaceholder(),
        ),
        Container(
          width: 48,
          height: 48,
          decoration: BoxDecoration(
            color: Colors.black54,
            shape: BoxShape.circle,
          ),
          child: const Icon(Icons.play_arrow_rounded,
              color: Colors.white, size: 30),
        ),
        if (p.duration != null)
          Positioned(
            bottom: 8,
            right: 8,
            child: Container(
              padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
              decoration: BoxDecoration(
                color: Colors.black54,
                borderRadius: BorderRadius.circular(4),
              ),
              child: Text(
                _formatDuration(p.duration!),
                style: const TextStyle(color: Colors.white, fontSize: 11),
              ),
            ),
          ),
      ],
    ),
  );
}