computeDisplayName function

String computeDisplayName(
  1. Map<String, List<String>> mappings,
  2. UserProfile profile
)

Combines mapped firstName/lastName into a display name, falling back to username then id.

Implementation

String computeDisplayName(
  Map<String, List<String>> mappings,
  model.UserProfile profile,
) {
  final fullName = [
    mapAttribute('firstName', mappings, profile),
    mapAttribute('lastName', mappings, profile),
  ].whereType<String>().join(' ').trim();
  if (fullName.isNotEmpty) return fullName;
  return mapAttribute('username', mappings, profile) ?? profile.id;
}