Avatar constructor

Avatar({
  1. required String name,
  2. String? imageUrl,
  3. ComponentSize size = ComponentSize.md,
  4. String? className,
  5. Map<String, Object?> props = const {},
  6. Map<String, Object?> style = const {},
  7. DartStyle? dartStyle,
})

Creates an avatar for name.

Implementation

Avatar({
  required String name,
  String? imageUrl,
  ComponentSize size = ComponentSize.md,
  String? className,
  Map<String, Object?> props = const {},
  Map<String, Object?> style = const {},
  DartStyle? dartStyle,
}) : super(
        imageUrl == null ? 'span' : 'img',
        props: mergeComponentProps(
          {
            ...props,
            if (imageUrl != null) ...{
              'src': imageUrl,
              'alt': name,
            } else
              'aria-label': name,
          },
          className: className,
          defaultStyle: {
            'display': 'inline-flex',
            'align-items': 'center',
            'justify-content': 'center',
            'width': _avatarSize(size),
            'height': _avatarSize(size),
            'border-radius': '999px',
            'background': '#eff4ff',
            'color': '#1849a9',
            'font-weight': 700,
            'object-fit': 'cover',
          },
          dartStyle: dartStyle,
          style: style,
        ),
        children: imageUrl == null ? [FlintText(_initials(name))] : const [],
      );