import 'package:cached_network_image/cached_network_image.dart';
import 'package:chat/configs/app_colors.dart';
import 'package:flutter/material.dart';

class MomentAvatar extends StatelessWidget {
  final String imageUrl;
  const MomentAvatar({Key? key, String? imageUrl})
      : imageUrl = imageUrl ?? '',
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 40,
      height: 40,
      child: DecoratedBox(
        decoration: BoxDecoration(
          borderRadius: const BorderRadius.all(Radius.circular(4)),
          color: AppColors.white,
          image: imageUrl.isNotEmpty
              ? DecorationImage(
                  image: CachedNetworkImageProvider(imageUrl),
                  fit: BoxFit.cover,
                )
              : null,
        ),
      ),
    );
  }
}
