import 'package:flutter/material.dart'; import 'package:marco/helpers/widgets/my_container.dart'; import 'package:marco/helpers/widgets/my_text.dart'; class Avatar extends StatelessWidget { final String firstName; final String lastName; final double size; final Color backgroundColor; final Color textColor; // Constructor const Avatar({ super.key, required this.firstName, required this.lastName, this.size = 46.0, // Default size this.backgroundColor = Colors.blue, // Default background color this.textColor = Colors.white, // Default text color }); @override Widget build(BuildContext context) { // Extract first letters of firstName and lastName String initials = "${firstName.isNotEmpty ? firstName[0] : ''}${lastName.isNotEmpty ? lastName[0] : ''}".toUpperCase(); return MyContainer.rounded( height: size, width: size, paddingAll: 0, color: backgroundColor, // Background color of the avatar child: Center( child: MyText.labelSmall( initials, fontWeight: 600, color: textColor, // Text color of the initials ), ), ); } }