Handle the behaviour of Reply/ReplyToList/ReplyAll button
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -55,13 +55,13 @@ import 'package:tmail_ui_user/features/composer/domain/usecases/restore_email_in
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/save_composer_cache_on_web_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/controller/rich_text_web_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/auto_create_tag_for_recipients_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/email_action_type_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/get_draft_mailbox_id_for_composer_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/get_outbox_mailbox_id_for_composer_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/get_sent_mailbox_id_for_composer_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/list_identities_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/list_shared_media_file_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/mail_address_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/mixin/drag_drog_file_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/create_email_request.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/draggable_email_address.dart';
|
||||
@@ -461,7 +461,7 @@ class ComposerController extends BaseController
|
||||
}
|
||||
|
||||
Future<void> _saveComposerCacheOnWebAction() async {
|
||||
_autoCreateEmailTag();
|
||||
autoCreateEmailTag();
|
||||
|
||||
final createEmailRequest = await _generateCreateEmailRequest();
|
||||
if (createEmailRequest == null) return;
|
||||
@@ -551,7 +551,7 @@ class ComposerController extends BaseController
|
||||
richTextMobileTabletController?.richTextController.hideRichTextView();
|
||||
}
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
autoCreateEmailTag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ class ComposerController extends BaseController
|
||||
listToEmailAddress.addAll(arguments.listEmailAddress ?? []);
|
||||
isInitialRecipient.value = true;
|
||||
toAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
break;
|
||||
case EmailActionType.composeFromMailtoUri:
|
||||
if (arguments.subject != null) {
|
||||
@@ -683,7 +683,7 @@ class ComposerController extends BaseController
|
||||
listBccEmailAddress = arguments.bcc!;
|
||||
}
|
||||
_getEmailContentFromMailtoUri(arguments.body ?? '');
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
break;
|
||||
case EmailActionType.reply:
|
||||
case EmailActionType.replyToList:
|
||||
@@ -760,7 +760,7 @@ class ComposerController extends BaseController
|
||||
toAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
}
|
||||
_getEmailContentFromUnsubscribeMailtoLink(arguments.body ?? '');
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -891,7 +891,7 @@ class ComposerController extends BaseController
|
||||
replyToAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
}
|
||||
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
}
|
||||
|
||||
void updateListEmailAddress(
|
||||
@@ -914,10 +914,10 @@ class ComposerController extends BaseController
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
}
|
||||
|
||||
void _updateStatusEmailSendButton() {
|
||||
void updateStatusEmailSendButton() {
|
||||
if (listToEmailAddress.isNotEmpty
|
||||
|| listCcEmailAddress.isNotEmpty
|
||||
|| listBccEmailAddress.isNotEmpty
|
||||
@@ -942,7 +942,7 @@ class ComposerController extends BaseController
|
||||
|| bccEmailAddressController.text.isNotEmpty
|
||||
|| replyToEmailAddressController.text.isNotEmpty) {
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
autoCreateEmailTag();
|
||||
}
|
||||
|
||||
if (!isEnableEmailSendButton.value) {
|
||||
@@ -1631,86 +1631,6 @@ class ComposerController extends BaseController
|
||||
replyToAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
}
|
||||
|
||||
void _autoCreateEmailTag() {
|
||||
final inputToEmail = toEmailAddressController.text;
|
||||
final inputCcEmail = ccEmailAddressController.text;
|
||||
final inputBccEmail = bccEmailAddressController.text;
|
||||
final inputReplyToEmail = replyToEmailAddressController.text;
|
||||
|
||||
if (inputToEmail.isNotEmpty) {
|
||||
_autoCreateToEmailTag(MailAddress.validateAddress(inputToEmail));
|
||||
}
|
||||
if (inputCcEmail.isNotEmpty) {
|
||||
_autoCreateCcEmailTag(MailAddress.validateAddress(inputCcEmail));
|
||||
}
|
||||
if (inputBccEmail.isNotEmpty) {
|
||||
_autoCreateBccEmailTag(MailAddress.validateAddress(inputBccEmail));
|
||||
}
|
||||
if (inputReplyToEmail.isNotEmpty) {
|
||||
_autoCreateReplyToEmailTag(MailAddress.validateAddress(inputReplyToEmail));
|
||||
}
|
||||
}
|
||||
|
||||
bool _isDuplicatedRecipient(String inputEmail, List<EmailAddress> listEmailAddress) {
|
||||
return listEmailAddress
|
||||
.map((emailAddress) => emailAddress.email)
|
||||
.whereNotNull()
|
||||
.contains(inputEmail);
|
||||
}
|
||||
|
||||
void _autoCreateToEmailTag(MailAddress inputMailAddress) {
|
||||
if (!_isDuplicatedRecipient(inputMailAddress.asEncodedString(), listToEmailAddress)) {
|
||||
listToEmailAddress.add(inputMailAddress.asEmailAddress());
|
||||
isInitialRecipient.value = true;
|
||||
isInitialRecipient.refresh();
|
||||
_updateStatusEmailSendButton();
|
||||
}
|
||||
log('ComposerController::_autoCreateToEmailTag(): STATE: ${keyToEmailTagEditor.currentState}');
|
||||
keyToEmailTagEditor.currentState?.resetTextField();
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
keyToEmailTagEditor.currentState?.closeSuggestionBox();
|
||||
});
|
||||
}
|
||||
|
||||
void _autoCreateCcEmailTag(MailAddress inputMailAddress) {
|
||||
if (!_isDuplicatedRecipient(inputMailAddress.asEncodedString(), listCcEmailAddress)) {
|
||||
listCcEmailAddress.add(inputMailAddress.asEmailAddress());
|
||||
isInitialRecipient.value = true;
|
||||
isInitialRecipient.refresh();
|
||||
_updateStatusEmailSendButton();
|
||||
}
|
||||
keyCcEmailTagEditor.currentState?.resetTextField();
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
keyCcEmailTagEditor.currentState?.closeSuggestionBox();
|
||||
});
|
||||
}
|
||||
|
||||
void _autoCreateBccEmailTag(MailAddress inputMailAddress) {
|
||||
if (!_isDuplicatedRecipient(inputMailAddress.asEncodedString(), listBccEmailAddress)) {
|
||||
listBccEmailAddress.add(inputMailAddress.asEmailAddress());
|
||||
isInitialRecipient.value = true;
|
||||
isInitialRecipient.refresh();
|
||||
_updateStatusEmailSendButton();
|
||||
}
|
||||
keyBccEmailTagEditor.currentState?.resetTextField();
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
keyBccEmailTagEditor.currentState?.closeSuggestionBox();
|
||||
});
|
||||
}
|
||||
|
||||
void _autoCreateReplyToEmailTag(MailAddress inputMailAddress) {
|
||||
if (!_isDuplicatedRecipient(inputMailAddress.asEncodedString(), listReplyToEmailAddress)) {
|
||||
listReplyToEmailAddress.add(inputMailAddress.asEmailAddress());
|
||||
isInitialRecipient.value = true;
|
||||
isInitialRecipient.refresh();
|
||||
_updateStatusEmailSendButton();
|
||||
}
|
||||
keyReplyToEmailTagEditor.currentState?.resetTextField();
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
keyReplyToEmailTagEditor.currentState?.closeSuggestionBox();
|
||||
});
|
||||
}
|
||||
|
||||
void _closeSuggestionBox() {
|
||||
if (toEmailAddressController.text.isEmpty) {
|
||||
keyToEmailTagEditor.currentState?.closeSuggestionBox();
|
||||
@@ -1778,29 +1698,29 @@ class ComposerController extends BaseController
|
||||
case PrefixEmailAddress.to:
|
||||
toAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
final inputToEmail = toEmailAddressController.text;
|
||||
if (inputToEmail.isNotEmpty) {
|
||||
_autoCreateToEmailTag(MailAddress.validateAddress(inputToEmail));
|
||||
if (inputToEmail.trim().isNotEmpty) {
|
||||
autoCreateEmailTagForType(PrefixEmailAddress.to, inputToEmail);
|
||||
}
|
||||
break;
|
||||
case PrefixEmailAddress.cc:
|
||||
ccAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
final inputCcEmail = ccEmailAddressController.text;
|
||||
if (inputCcEmail.isNotEmpty) {
|
||||
_autoCreateCcEmailTag(MailAddress.validateAddress(inputCcEmail));
|
||||
if (inputCcEmail.trim().isNotEmpty) {
|
||||
autoCreateEmailTagForType(PrefixEmailAddress.cc, inputCcEmail);
|
||||
}
|
||||
break;
|
||||
case PrefixEmailAddress.bcc:
|
||||
bccAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
final inputBccEmail = bccEmailAddressController.text;
|
||||
if (inputBccEmail.isNotEmpty) {
|
||||
_autoCreateBccEmailTag(MailAddress.validateAddress(inputBccEmail));
|
||||
if (inputBccEmail.trim().isNotEmpty) {
|
||||
autoCreateEmailTagForType(PrefixEmailAddress.bcc, inputBccEmail);
|
||||
}
|
||||
break;
|
||||
case PrefixEmailAddress.replyTo:
|
||||
replyToAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
final inputReplyToEmail = replyToEmailAddressController.text;
|
||||
if (inputReplyToEmail.isNotEmpty) {
|
||||
_autoCreateReplyToEmailTag(MailAddress.validateAddress(inputReplyToEmail));
|
||||
if (inputReplyToEmail.trim().isNotEmpty) {
|
||||
autoCreateEmailTagForType(PrefixEmailAddress.replyTo, inputReplyToEmail);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1866,7 +1786,7 @@ class ComposerController extends BaseController
|
||||
ccAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
bccAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
bccAddressExpandMode.refresh();
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
}
|
||||
|
||||
void _removeBccEmailAddressFromFormerIdentity(Set<EmailAddress> listEmailAddress) {
|
||||
@@ -1879,7 +1799,7 @@ class ComposerController extends BaseController
|
||||
toAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
ccAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
bccAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
}
|
||||
|
||||
Future<void> _applySignature(String signature) async {
|
||||
@@ -1952,7 +1872,7 @@ class ComposerController extends BaseController
|
||||
richTextMobileTabletController?.richTextController.showDeviceKeyboard);
|
||||
}
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
autoCreateEmailTag();
|
||||
}
|
||||
|
||||
void _onChangeCursorOnMobile(List<int>? coordinates, BuildContext context) {
|
||||
@@ -2083,7 +2003,7 @@ class ComposerController extends BaseController
|
||||
|
||||
void handleOnMouseDownHtmlEditorWeb() {
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
autoCreateEmailTag();
|
||||
}
|
||||
|
||||
FocusNode? getNextFocusOfToEmailAddress() {
|
||||
@@ -2117,7 +2037,7 @@ class ComposerController extends BaseController
|
||||
}
|
||||
|
||||
void handleFocusNextAddressAction() {
|
||||
_autoCreateEmailTag();
|
||||
autoCreateEmailTag();
|
||||
}
|
||||
|
||||
bool get isNetworkConnectionAvailable => networkConnectionController.isNetworkConnectionAvailable();
|
||||
@@ -2176,7 +2096,7 @@ class ComposerController extends BaseController
|
||||
isInitialRecipient.value = true;
|
||||
isInitialRecipient.refresh();
|
||||
|
||||
_updateStatusEmailSendButton();
|
||||
updateStatusEmailSendButton();
|
||||
}
|
||||
|
||||
void onAttachmentDropZoneListener(Attachment attachment) {
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
|
||||
import 'package:core/utils/mail/mail_address.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/email/prefix_email_address.dart';
|
||||
import 'package:super_tag_editor/tag_editor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/mail_address_extension.dart';
|
||||
|
||||
extension AutoCreateTagForRecipientsExtension on ComposerController {
|
||||
|
||||
void autoCreateEmailTag() {
|
||||
final emailInputs = {
|
||||
PrefixEmailAddress.to: toEmailAddressController.text,
|
||||
PrefixEmailAddress.cc: ccEmailAddressController.text,
|
||||
PrefixEmailAddress.bcc: bccEmailAddressController.text,
|
||||
PrefixEmailAddress.replyTo: replyToEmailAddressController.text,
|
||||
};
|
||||
|
||||
emailInputs.forEach((prefix, input) {
|
||||
if (input.trim().isNotEmpty) {
|
||||
autoCreateEmailTagForType(prefix, input);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Map<PrefixEmailAddress, List<EmailAddress>> get _emailLists => {
|
||||
PrefixEmailAddress.to: listToEmailAddress,
|
||||
PrefixEmailAddress.cc: listCcEmailAddress,
|
||||
PrefixEmailAddress.bcc: listBccEmailAddress,
|
||||
PrefixEmailAddress.replyTo: listReplyToEmailAddress,
|
||||
};
|
||||
|
||||
Map<PrefixEmailAddress, GlobalKey<TagsEditorState>> get _emailEditors => {
|
||||
PrefixEmailAddress.to: keyToEmailTagEditor,
|
||||
PrefixEmailAddress.cc: keyCcEmailTagEditor,
|
||||
PrefixEmailAddress.bcc: keyBccEmailTagEditor,
|
||||
PrefixEmailAddress.replyTo: keyReplyToEmailTagEditor,
|
||||
};
|
||||
|
||||
void autoCreateEmailTagForType(PrefixEmailAddress type, String input) {
|
||||
final emailAddressRecord = _generateEmailAddressFromString(input);
|
||||
|
||||
final emailList = _emailLists[type]!;
|
||||
final keyEditor = _emailEditors[type]!;
|
||||
|
||||
final emailSet = emailList.toSet();
|
||||
if (emailSet.any((email) => email.email == emailAddressRecord.$1)) return;
|
||||
|
||||
emailSet.add(emailAddressRecord.$2);
|
||||
emailList
|
||||
..clear()
|
||||
..addAll(emailSet);
|
||||
|
||||
isInitialRecipient.value = true;
|
||||
isInitialRecipient.refresh();
|
||||
updateStatusEmailSendButton();
|
||||
|
||||
keyEditor.currentState?.resetTextField();
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 300),
|
||||
keyEditor.currentState?.closeSuggestionBox,
|
||||
);
|
||||
}
|
||||
|
||||
(String email, EmailAddress emailAddress) _generateEmailAddressFromString(String input) {
|
||||
try {
|
||||
final mailAddress = MailAddress.validateAddress(input);
|
||||
return (mailAddress.asEncodedString(), mailAddress.asEmailAddress());
|
||||
} catch (e) {
|
||||
return (input, EmailAddress(null, input));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
@@ -230,7 +229,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
return RecipientSuggestionItemWidget(
|
||||
imagePaths: widget.imagePaths,
|
||||
suggestionState: suggestionEmailAddress.state,
|
||||
emailAddress: MailAddress.validateAddress(suggestionEmailAddress.emailAddress.emailAddress).asEmailAddress(),
|
||||
emailAddress: _subAddressingValidatedEmailAddress(suggestionEmailAddress.emailAddress),
|
||||
suggestionValid: suggestionValid,
|
||||
highlight: highlight,
|
||||
onSelectedAction: (emailAddress) {
|
||||
@@ -321,7 +320,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
return RecipientSuggestionItemWidget(
|
||||
imagePaths: widget.imagePaths,
|
||||
suggestionState: suggestionEmailAddress.state,
|
||||
emailAddress: MailAddress.validateAddress(suggestionEmailAddress.emailAddress.emailAddress).asEmailAddress(),
|
||||
emailAddress: _subAddressingValidatedEmailAddress(suggestionEmailAddress.emailAddress),
|
||||
suggestionValid: suggestionValid,
|
||||
highlight: highlight,
|
||||
onSelectedAction: (emailAddress) {
|
||||
@@ -466,13 +465,10 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
}
|
||||
|
||||
bool _isDuplicatedRecipient(String inputEmail) {
|
||||
if (inputEmail.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
if (inputEmail.trim().isEmpty) return false;
|
||||
|
||||
return _currentListEmailAddress
|
||||
.map((emailAddress) => emailAddress.email)
|
||||
.whereNotNull()
|
||||
.contains(inputEmail);
|
||||
.any((emailAddress) => emailAddress.email?.trim() == inputEmail.trim());
|
||||
}
|
||||
|
||||
SuggestionEmailAddress _toSuggestionEmailAddress(EmailAddress item, List<EmailAddress> addedEmailAddresses) {
|
||||
@@ -524,13 +520,10 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
void _handleSelectOptionAction(
|
||||
SuggestionEmailAddress suggestionEmailAddress,
|
||||
StateSetter stateSetter
|
||||
) {
|
||||
MailAddress mailAddress = MailAddress.validateAddress(suggestionEmailAddress.emailAddress.emailAddress);
|
||||
if (!_isDuplicatedRecipient(mailAddress.asEncodedString())) {
|
||||
stateSetter(() => _currentListEmailAddress.add(mailAddress.asEmailAddress()));
|
||||
_updateListEmailAddressAction();
|
||||
}
|
||||
}
|
||||
) => _onEmailAddressReceived(
|
||||
suggestionEmailAddress.emailAddress.emailAddress,
|
||||
stateSetter,
|
||||
);
|
||||
|
||||
void _handleSubmitTagAction(
|
||||
String value,
|
||||
@@ -539,11 +532,9 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
|
||||
void _createMailTag(String value, StateSetter stateSetter) {
|
||||
final listString = StringConvert.extractStrings(value.trim()).toSet();
|
||||
MailAddress mailAddress = MailAddress.validateAddress(value.trim());
|
||||
|
||||
if (listString.isEmpty && !_isDuplicatedRecipient(mailAddress.asEncodedString())) {
|
||||
stateSetter(() => _currentListEmailAddress.add(mailAddress.asEmailAddress()));
|
||||
_updateListEmailAddressAction();
|
||||
if (listString.isEmpty && !_isDuplicatedRecipient(value)) {
|
||||
_onEmailAddressReceived(value, stateSetter);
|
||||
} else if (listString.isNotEmpty) {
|
||||
final listStringNotExist = listString
|
||||
.where((text) => !_isDuplicatedRecipient(text))
|
||||
@@ -564,11 +555,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
String value,
|
||||
StateSetter stateSetter
|
||||
) {
|
||||
MailAddress mailAddress = MailAddress.validateAddress(value.trim());
|
||||
if (!_isDuplicatedRecipient(mailAddress.asEncodedString())) {
|
||||
stateSetter(() => _currentListEmailAddress.add(mailAddress.asEmailAddress()));
|
||||
_updateListEmailAddressAction();
|
||||
}
|
||||
_onEmailAddressReceived(value, stateSetter);
|
||||
_gapBetweenTagChangedAndFindSuggestion = Timer(
|
||||
const Duration(seconds: 1),
|
||||
_handleGapBetweenTagChangedAndFindSuggestion
|
||||
@@ -608,4 +595,30 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void _onEmailAddressReceived(String input, StateSetter stateSetter) {
|
||||
final emailAddressRecord = _generateEmailAddressFromString(input);
|
||||
if (!_isDuplicatedRecipient(emailAddressRecord.$1)) {
|
||||
stateSetter(() => _currentListEmailAddress.add(emailAddressRecord.$2));
|
||||
_updateListEmailAddressAction();
|
||||
}
|
||||
}
|
||||
|
||||
EmailAddress _subAddressingValidatedEmailAddress(EmailAddress emailAddress) {
|
||||
try {
|
||||
final mailAddress = MailAddress.validateAddress(emailAddress.emailAddress);
|
||||
return mailAddress.asEmailAddress();
|
||||
} catch (e) {
|
||||
return emailAddress;
|
||||
}
|
||||
}
|
||||
|
||||
(String email, EmailAddress emailAddress) _generateEmailAddressFromString(String input) {
|
||||
try {
|
||||
final mailAddress = MailAddress.validateAddress(input);
|
||||
return (mailAddress.asEncodedString(), mailAddress.asEmailAddress());
|
||||
} catch (e) {
|
||||
return (input, EmailAddress(null, input));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user