getLastChapter static method

Chapter? getLastChapter(
  1. dynamic book
)

Returns a Chapter object that corresponds to the last chapter within a book.

Implementation

static Chapter? getLastChapter(dynamic book) {
  int? bookNumber;
  if (book is int) {
    bookNumber = book;
  } else if (book is String) {
    bookNumber = findBookNumber(book);
  } else {
    return null;
  }
  if (bookNumber == null) {
    return null;
  }
  if (BibleData.lastVerse.length < bookNumber) {
    return null;
  }
  var bookNames = getBookNames(book);
  book = bookNames['name'];
  var chapter = BibleData.lastVerse[bookNumber - 1].length;

  return Chapter(book, chapter);
}