feat: Implement image cache eviction for S3 images and enhance image loading error handling.

This commit is contained in:
pradeepkumar
2026-03-14 15:26:08 +05:30
parent ad94db5620
commit 7b9c19ec67
4 changed files with 53 additions and 35 deletions

View File

@@ -1,10 +1,12 @@
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import 'package:real_estate_mobile/core/constants/app_colors.dart';
import 'package:real_estate_mobile/core/utils/image_url_resolver.dart';
import 'package:real_estate_mobile/core/widgets/s3_image.dart';
import 'package:real_estate_mobile/features/profile/data/profile_repository.dart';
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
@@ -99,6 +101,13 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
avatarUrl = user?['avatar'] as String?;
}
// Evict stale presigned URL cache and disk cache for the avatar
// so S3Image always resolves a fresh presigned URL on profile load.
if (avatarUrl != null && avatarUrl.isNotEmpty) {
ImageUrlResolver.instance.evict(avatarUrl);
CachedNetworkImage.evictFromCache(avatarUrl);
}
final descriptionText = isAgent
? 'This information will be displayed on your public agent page.'
: 'This information will be displayed on your profile.';