feat: add matchPercentage field to AgentProfile and display match badge in agent search results

This commit is contained in:
pradeepkumar
2026-03-28 20:08:28 +05:30
parent ecca0a37c3
commit 74d53dbed3
2 changed files with 27 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ class AgentProfile {
final List<String> legacySpecializations; final List<String> legacySpecializations;
final List<String> languages; final List<String> languages;
final List<String> serviceAreas; final List<String> serviceAreas;
final int? matchPercentage;
const AgentProfile({ const AgentProfile({
required this.id, required this.id,
@@ -61,6 +62,7 @@ class AgentProfile {
this.legacySpecializations = const [], this.legacySpecializations = const [],
this.languages = const [], this.languages = const [],
this.serviceAreas = const [], this.serviceAreas = const [],
this.matchPercentage,
}); });
String get fullName => '$firstName $lastName'.trim(); String get fullName => '$firstName $lastName'.trim();
@@ -279,6 +281,7 @@ class AgentProfile {
?.map((e) => e.toString()) ?.map((e) => e.toString())
.toList() ?? .toList() ??
const [], const [],
matchPercentage: json['matchPercentage'] as int?,
); );
} }
} }

View File

@@ -528,6 +528,30 @@ class _AgentCardState extends State<_AgentCard> {
), ),
), ),
], ],
// Match badge
if (agent.matchPercentage != null) ...[
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: agent.matchPercentage! >= 80
? const Color(0xFF638559)
: agent.matchPercentage! >= 65
? const Color(0xFF7D917D)
: AppColors.primaryDark.withValues(alpha: 0.6),
borderRadius: BorderRadius.circular(20),
),
child: Text(
'${agent.matchPercentage}% Match',
style: const TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 12,
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
],
], ],
), ),
const SizedBox(height: 4), const SizedBox(height: 4),