getInitials static method

String getInitials(
  1. String string
)

Implementation

static String getInitials(String string) {
  List<String> names = string.split(" ");
  String initials = "";
  int numWords = 1;
  if (numWords < names.length) {
    numWords = names.length;
  }
  for (var i = 0; i < numWords; i++) {
    initials += '${names[i][0]}';
  }
  return initials;
}