createMailbox method Null safety

Future<Mailbox> createMailbox(
  1. String mailboxName,
  2. {Mailbox? parentMailbox}
)

Creates a new mailbox with the given mailboxName.

Specify a parentMailbox in case the mailbox should not be created in the root.

Implementation

Future<Mailbox> createMailbox(String mailboxName,
    {Mailbox? parentMailbox}) async {
  if (!supportsMailboxes) {
    throw MailException(
        this, 'Mailboxes are not supported, check "supportsMailboxes" first');
  }
  final box = await _incomingMailClient.createMailbox(mailboxName,
      parentMailbox: parentMailbox);
  _mailboxes?.add(box);
  return box;
}