Skip to content

Commit 40bc031

Browse files
committed
content: Have AvatarImage handle a missing user
Discussion: zulip#249 (comment)
1 parent 46b4eb7 commit 40bc031

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/widgets/content.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ class Avatar extends StatelessWidget {
836836

837837
/// The appropriate avatar image for a user ID.
838838
///
839+
/// If the user isn't found, gives a [SizedBox.shrink].
840+
///
839841
/// Wrap this with [AvatarShape].
840842
class AvatarImage extends StatelessWidget {
841843
const AvatarImage({
@@ -848,7 +850,12 @@ class AvatarImage extends StatelessWidget {
848850
@override
849851
Widget build(BuildContext context) {
850852
final store = PerAccountStoreWidget.of(context);
851-
final user = store.users[userId]!;
853+
final user = store.users[userId];
854+
855+
if (user == null) {
856+
// TODO(log) log?
857+
return const SizedBox.shrink();
858+
}
852859

853860
final resolvedUrl = switch (user.avatarUrl) {
854861
null => null, // TODO(#255): handle computing gravatars

0 commit comments

Comments
 (0)