copyWithAuthenticationUserName method
Convenience method to update the incoming and outgoing authentication user name for identifying the user towards the mail service.
Implementation
MailAccount copyWithAuthenticationUserName(String authenticationUserName) {
var incomingAuth = incoming.authentication;
if (incomingAuth is UserNameBasedAuthentication) {
incomingAuth = incomingAuth.copyWithUserName(authenticationUserName);
}
var outgoingAuth = outgoing.authentication;
if (outgoingAuth is UserNameBasedAuthentication) {
outgoingAuth = outgoingAuth.copyWithUserName(authenticationUserName);
}
return copyWith(
incoming: incoming.copyWith(authentication: incomingAuth),
outgoing: outgoing.copyWith(authentication: outgoingAuth),
);
}