fromPage method Null safety

MessageSequence fromPage(
  1. int page,
  2. int pageSize,
  3. dynamic messagesExist,
  4. {bool isUidSequence = false}
)

Convenience method for getting the sequence for a range defined by the page starting with 1, the pageSize and the number of messages messagesExist.

Implementation

static MessageSequence fromPage(int page, int pageSize, messagesExist,
    {bool isUidSequence = false}) {
  final rangeStart = messagesExist - page * pageSize;

  if (page == 1) {
    // ensure that also get any new messages:
    return fromRangeToLast(rangeStart < 1 ? 1 : rangeStart,
        isUidSequence: isUidSequence);
  }
  final rangeEnd = rangeStart + pageSize;
  return fromRange(rangeStart < 1 ? 1 : rangeStart, rangeEnd,
      isUidSequence: isUidSequence);
}