setAvatar method

Future<void> setAvatar(
  1. SDNFile? file
)

Uploads a new user avatar for this user. Leave file null to remove the current avatar.

Implementation

Future<void> setAvatar(SDNFile? file) async {
  if (file == null) {
    // We send an empty String to remove the avatar. Sending Null **should**
    // work but it doesn't with Synapse. See:
    // https://gitlab.com/famedly/company/frontend/famedlysdk/-/issues/254
    return setAvatarUrl(userID!, Uri.parse(''));
  }
  final uploadResp = await uploadContent(
    file.bytes,
    filename: file.name,
    contentType: file.mimeType,
  );
  await setAvatarUrl(userID!, uploadResp);
  return;
}