diff --git a/mobile/lib/shared/ui/user_avatar.dart b/mobile/lib/shared/ui/user_avatar.dart index 23272870ea..c736e8f900 100644 --- a/mobile/lib/shared/ui/user_avatar.dart +++ b/mobile/lib/shared/ui/user_avatar.dart @@ -6,6 +6,8 @@ import 'package:immich_mobile/shared/models/user.dart'; Widget userAvatar(BuildContext context, User u, {double? radius}) { final url = "${Store.get(StoreKey.serverEndpoint)}/user/profile-image/${u.id}"; + final firstNameFirstLetter = u.firstName.isNotEmpty ? u.firstName[0] : ""; + final lastNameFirstLetter = u.lastName.isNotEmpty ? u.lastName[0] : ""; return CircleAvatar( radius: radius, backgroundColor: Theme.of(context).primaryColor.withAlpha(50), @@ -16,6 +18,6 @@ Widget userAvatar(BuildContext context, User u, {double? radius}) { ), // silence errors if user has no profile image, use initials as fallback onForegroundImageError: (exception, stackTrace) {}, - child: Text((u.firstName[0] + u.lastName[0]).toUpperCase()), + child: Text((firstNameFirstLetter + lastNameFirstLetter).toUpperCase()), ); }