getLastVerse static method
Creates a Verse object for the last verse in a book or chapter.
Implementation
static Verse? getLastVerse(dynamic book, [int? chapter]) {
int? bookNumber;
if (book is int) {
bookNumber = book;
} else if (book is String) {
bookNumber = findBookNumber(book);
} else {
return null;
}
if (bookNumber == null) {
return null;
}
var bookNames = getBookNames(book);
book = bookNames['name'];
chapter ??= BibleData.lastVerse[bookNumber - 1].length;
if (BibleData.lastVerse[bookNumber - 1].length < chapter || chapter < 1) {
return null;
}
var lastVerse = BibleData.lastVerse[bookNumber - 1][chapter - 1];
return Verse(book, chapter, lastVerse);
}