fromMessages method Null safety

MessageSequence fromMessages(
  1. List<MimeMessage> messages

Convenience method for getting the sequence for the given messages's UIDs or sequence IDs.


static MessageSequence fromMessages(List<MimeMessage> messages) {
  if (messages.isEmpty) {
    throw StateError('Messages must not be empty or null: $messages');
  final isUid = (messages.first.uid != null);
  final sequence = MessageSequence(isUidSequence: isUid);
  for (final message in messages) {
    sequence.add(isUid ? message.uid! : message.sequenceId!);
  return sequence;