UserAvatar constructor

UserAvatar({
  1. Key? key,
  2. required BuildContext context,
  3. Color? backgroundColor,
  4. Color? foregroundColor,
  5. double? radius,
  6. TextStyle? textStyle,
  7. String? userImageUrl,
  8. String? userName,
})

Implementation

UserAvatar({
  super.key,
  required BuildContext context,
  Color? backgroundColor,
  Color? foregroundColor,
  double? radius,
  this.textStyle,
  this.userImageUrl,
  this.userName,
})  : assert(userName?.isNotEmpty == true || userImageUrl != null),
      super(
        radius: radius,
        backgroundColor:
            backgroundColor ?? Theme.of(context).colorScheme.primary,
        backgroundImage:
            userImageUrl == null ? null : NetworkImage(userImageUrl),
        child: userImageUrl == null
            ? Text(
                userName!.toInitials(),
                style: textStyle ??
                    Theme.of(context).textTheme.titleSmall?.copyWith(
                          color: foregroundColor ?? Colors.white,
                          fontSize: radius != null ? radius * 0.75 : null,
                        ),
              )
            : null,
      );