bifurcateFullName static method

List<String?> bifurcateFullName(
  1. String? fullName
)

Bifurcate full name into given name & surname.

  • @returnValue A list that always has 2 items, which may be null.

Implementation

static List<String?> bifurcateFullName(String? fullName)
{
  List<String?> bifurcatedName = [null, null];
  if (fullName != null && fullName.isNotEmpty) {
    List<String> fullNameParts = fullName.split(_NAME_PART_SEPARATOR);
    bifurcatedName[0] = fullNameParts.first;
    // The rest of the parts are placed in the last name.
    bifurcatedName[1] = fullNameParts.skip(1).join(_NAME_PART_SEPARATOR);
  }
  return bifurcatedName;
}