getShortOfName function

String getShortOfName(
  1. String name
)

Implementation

String getShortOfName(String name) {
  name = name.trim();
  List<String> names = name.split(" ");
  String shortForm = "";
  shortForm += names.first[0].toUpperCase();
  if (names.length > 1) shortForm += names.last[0].toUpperCase();
  return shortForm;
}