formatInitials function

String formatInitials(
  1. String? value
)

Formats a string value to its initials. Returns the first two initials of the input string. If the input is null or empty, returns 'n/a'.

Implementation

String formatInitials(String? value) {
  if (value == null) return formatNullable(value);
  return value.isNotEmpty
      ? value.trim().split(RegExp(' +')).map((s) => s[0]).take(2).join()
      : '';
}