getBackgroundColour static method

Color getBackgroundColour(
  1. String name
)

This function is used to get the avatar background colour

Implementation

static Color getBackgroundColour(String name) {
  if (name.isEmpty) {
    return avatarColors[0];
  }
  if (name.contains(regexEmoji)) {
    name = name.replaceAll(regexEmoji, '');
    if (name.trim().isEmpty) {
      return avatarColors[0];
    }
  }
  return avatarColors[name.toUpperCase().codeUnitAt(0) % avatarColors.length];
}