From f614a2bab4695a61df13c873faa57f7051fba114 Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 17 Feb 2023 16:19:34 +0700 Subject: [PATCH] Fix crash when advanced search with only select attachment --- model/lib/email/presentation_email.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/model/lib/email/presentation_email.dart b/model/lib/email/presentation_email.dart index 532f6b214..126e3a108 100644 --- a/model/lib/email/presentation_email.dart +++ b/model/lib/email/presentation_email.dart @@ -55,7 +55,13 @@ class PresentationEmail with EquatableMixin { } ); - String getSenderName() => from?.first.asString() ?? ''; + String getSenderName() { + if (from?.isNotEmpty == true) { + return from?.first.asString() ?? ''; + } else { + return ''; + } + } String getAvatarText() { if (getSenderName().isNotEmpty) { @@ -76,7 +82,13 @@ class PresentationEmail with EquatableMixin { bool get withAttachments => hasAttachment == true; - String get mailboxName => mailboxNames?.first?.name ?? ''; + String get mailboxName { + if (mailboxNames?.isNotEmpty == true) { + return mailboxNames?.first?.name ?? ''; + } else { + return ''; + } + } String get routeWebAsString => routeWeb.toString();