updateProfile method

Future<void> updateProfile({
  1. String? displayName,
  2. String? avatarUrl,
})

Update top-level profile fields (display name, avatar). Pass only the fields that should change; nulls are ignored.

Implementation

Future<void> updateProfile({String? displayName, String? avatarUrl}) async {
  final userId = _client.auth.currentUser?.id;
  if (userId == null) return;

  final patch = <String, dynamic>{};
  if (displayName != null) patch['display_name'] = displayName;
  if (avatarUrl != null) patch['avatar_url'] = avatarUrl;
  if (patch.isEmpty) return;

  await _client.from('profiles').update(patch).eq('id', userId);
}