getMailboxes method

Future<List<MailBox>> getMailboxes()

Implementation

Future<List<MailBox>> getMailboxes() async {
  List<Mailbox> mailboxes = await _client.listMailboxes();
  //remove all mailboxes that are not an email folder
  mailboxes.removeWhere(
      (element) => !element.flags.contains(MailboxFlag.hasNoChildren));
  List<MailBox> mailBoxList =
      mailboxes.map((e) => MailBox.fromMailLib(e)).toList();
  if (mailBoxList.indexWhere((element) => element.name == "Boîte d'envoi") ==
      -1) {
    mailBoxList.add(MailBox(name: "Boîte d'envoi", emails: const []));
  }
  return mailBoxList;
}