fix: improve image caching reliability by clearing cache on startup and forcing widget rebuilds on tab switches
This commit is contained in:
@@ -75,6 +75,7 @@ class _TopProfessionalsSectionState
|
||||
final activeList = _activeTab == 'agents' ? cmsAgents : cmsLenders;
|
||||
final isLoading = homeState.isLoading;
|
||||
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
@@ -107,14 +108,19 @@ class _TopProfessionalsSectionState
|
||||
SizedBox(
|
||||
height: 540,
|
||||
child: ListView.builder(
|
||||
// Unique key per tab forces Flutter to rebuild (not reuse)
|
||||
// the list items, preventing stale images from the other tab.
|
||||
key: ValueKey('professionals_$_activeTab'),
|
||||
controller: _scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: const EdgeInsets.only(bottom: 16, left: 10, right: 10),
|
||||
itemCount: activeList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = activeList[index];
|
||||
final cardWidth = MediaQuery.of(context).size.width - 48;
|
||||
return SizedBox(
|
||||
key: ValueKey('${_activeTab}_${item.name}_$index'),
|
||||
width: cardWidth,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -122,7 +128,7 @@ class _TopProfessionalsSectionState
|
||||
right: index == activeList.length - 1 ? 0 : 8,
|
||||
),
|
||||
child: _buildProfessionalCard(
|
||||
activeList[index],
|
||||
item,
|
||||
index: index,
|
||||
),
|
||||
),
|
||||
@@ -322,6 +328,10 @@ class _TopProfessionalsSectionState
|
||||
),
|
||||
child: imageUrl.isNotEmpty
|
||||
? S3Image(
|
||||
// Unique key per tab+imageUrl ensures Flutter creates
|
||||
// a brand-new S3Image (with fresh _resolvedUrl state)
|
||||
// when switching between Agents and Lenders tabs.
|
||||
key: ValueKey('${_activeTab}_$imageUrl'),
|
||||
imageUrl: imageUrl,
|
||||
width: double.infinity,
|
||||
height: 226,
|
||||
|
||||
@@ -135,9 +135,9 @@ class Conversation {
|
||||
createdAt: json['createdAt'] as String,
|
||||
updatedAt: json['updatedAt'] as String,
|
||||
otherParty:
|
||||
OtherParty.fromJson(json['otherParty'] as Map<String, dynamic>),
|
||||
OtherParty.fromJson(MessageSender._safeMap(json['otherParty'])),
|
||||
messages: (json['messages'] as List<dynamic>?)
|
||||
?.map((e) => ChatMessage.fromJson(e as Map<String, dynamic>))
|
||||
?.map((e) => ChatMessage.fromJson(MessageSender._safeMap(e)))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user