perf: fix image loading performance across all screens

- Replace Image.network (no cache) with CachedNetworkImage in contributor_profile_screen
- Replace NetworkImage (no cache) with CachedNetworkImageProvider in desktop_topbar and contribute_screen (leaderboard avatars)
- Add maxWidthDiskCache + maxHeightDiskCache to all 23 CachedNetworkImage calls
- Add missing memCacheWidth/Height to review_card (36x36 avatar) and learn_more related events (140x100)
- Add dynamic memCache sizing to tier_avatar_ring based on widget size

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 20:03:03 +05:30
parent 5e00e431e3
commit 754b04dc05
10 changed files with 90 additions and 11 deletions

View File

@@ -15,6 +15,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:provider/provider.dart';
import '../features/events/services/events_service.dart';
import '../features/events/models/event_models.dart';
import '../core/auth/auth_guard.dart';
import '../features/gamification/providers/gamification_provider.dart';
import '../features/gamification/models/gamification_models.dart';
import '../widgets/skeleton_loader.dart';
@@ -123,9 +124,11 @@ class _ProfileScreenState extends State<ProfileScreen>
_loadProfile();
_startAnimations();
// Load gamification data for profile EP cards
// Load gamification data for profile EP cards — skip for guests (endpoints authed).
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) context.read<GamificationProvider>().loadAll(force: true);
if (mounted && !AuthGuard.isGuest) {
context.read<GamificationProvider>().loadAll(force: true);
}
});
}
@@ -1047,6 +1050,8 @@ class _ProfileScreenState extends State<ProfileScreen>
imageUrl: imageUrl,
memCacheWidth: 120,
memCacheHeight: 120,
maxWidthDiskCache: 240,
maxHeightDiskCache: 240,
width: 60,
height: 60,
fit: BoxFit.cover,
@@ -2552,6 +2557,8 @@ class _ProfileScreenState extends State<ProfileScreen>
imageUrl: imageUrl,
memCacheWidth: 400,
memCacheHeight: 400,
maxWidthDiskCache: 800,
maxHeightDiskCache: 800,
width: double.infinity,
height: double.infinity,
fit: BoxFit.cover,