getInitials static method

dynamic getInitials(
  1. String fullName
)

Implementation

static getInitials(String fullName) {
  // Split the full name by spaces
  List<String> words = fullName.split(' ');

  // Extract the first letter of each word, convert to uppercase, and join
  String initials = words
      .map((word) => word.isNotEmpty ? word[0].toUpperCase() : '')
      .join();

  return initials;
}