refactor: update contact email and phone priority logic in agent detail provider to match web implementation

This commit is contained in:
pradeepkumar
2026-04-09 22:08:24 +05:30
parent b97113b10a
commit 9c79c05c52

View File

@@ -245,20 +245,29 @@ class AgentDetailState {
// ── Contact info (masked) ──
/// Contact email — matches web priority: agentProfile.email first,
/// then user login email, then dynamic field values as fallback.
String? get contactEmail {
final val = _getFieldValue('email') ??
_getFieldValue('email_address') ??
agent?.email ??
agent?.user?.email;
final profileEmail = agent?.email;
if (profileEmail != null && profileEmail.isNotEmpty) return profileEmail;
final userEmail = agent?.user?.email;
if (userEmail != null && userEmail.isNotEmpty) return userEmail;
final val = _getFieldValue('email') ?? _getFieldValue('email_address');
return val?.toString();
}
/// Contact phone — matches web priority: agentProfile.phone first,
/// then dynamic field values as fallback.
String? get contactPhone {
final profilePhone = agent?.phone;
if (profilePhone != null && profilePhone.isNotEmpty) return profilePhone;
final val = _getFieldValue('phone_number') ??
_getFieldValue('phone') ??
_getFieldValue('cell_number') ??
_getFieldValue('office_number') ??
agent?.phone;
_getFieldValue('office_number');
return val?.toString();
}