getClientByEmail<T> function
Find client by email in provided clients list or throw a clear error.
Find client by email in provided clients list or throw a clear error.
This method is generic and will return the found element cast to T.
Implementation
T getClientByEmail<T>(List<T> clients, String? email, String inboundTag) {
return clients.cast<T>().firstWhere(
(c) => ((c as dynamic).email ?? '') == email,
orElse: () => throw ArgumentError(
'Client for Email = $email not found in inbound $inboundTag',
),
);
}