uploadAvatar method
Uploads bytes as the user's new avatar.
Implementation
Future<void> uploadAvatar(Uint8List bytes) async {
final current = await ref.read(currentUserProfileProvider.future);
// Evict the old image before uploading. The new URL carries a fresh
// cache-buster so the old entry would never be requested again anyway;
// evicting reclaims disk and memory now instead of at LRU expiry.
final oldUrl = resolveAvatarUrl(
current.avatarUrl,
ref.read(appConfigProvider).engine.apiBaseUrl,
);
if (oldUrl != null) await CachedNetworkImageProvider(oldUrl).evict();
await _apply(
await ref.read(avatarStorageServiceProvider).uploadAvatar(bytes),
);
}