enum Testament { old, newT } class Book { const Book({ required this.index, required this.name, required this.chapterCount, required this.testament, }); final int index; final String name; final int chapterCount; final Testament testament; } class Bible { const Bible._(); static const List books = [ Book(index: 0, name: 'Genesis', chapterCount: 50, testament: Testament.old), Book(index: 1, name: 'Exodus', chapterCount: 40, testament: Testament.old), Book( index: 2, name: 'Leviticus', chapterCount: 27, testament: Testament.old, ), Book(index: 3, name: 'Numbers', chapterCount: 36, testament: Testament.old), Book( index: 4, name: 'Deuteronomy', chapterCount: 34, testament: Testament.old, ), Book(index: 5, name: 'Joshua', chapterCount: 24, testament: Testament.old), Book(index: 6, name: 'Judges', chapterCount: 21, testament: Testament.old), Book(index: 7, name: 'Ruth', chapterCount: 4, testament: Testament.old), Book( index: 8, name: '1 Samuel', chapterCount: 31, testament: Testament.old, ), Book( index: 9, name: '2 Samuel', chapterCount: 24, testament: Testament.old, ), Book( index: 10, name: '1 Kings', chapterCount: 22, testament: Testament.old, ), Book( index: 11, name: '2 Kings', chapterCount: 25, testament: Testament.old, ), Book( index: 12, name: '1 Chronicles', chapterCount: 29, testament: Testament.old, ), Book( index: 13, name: '2 Chronicles', chapterCount: 36, testament: Testament.old, ), Book(index: 14, name: 'Ezra', chapterCount: 10, testament: Testament.old), Book( index: 15, name: 'Nehemiah', chapterCount: 13, testament: Testament.old, ), Book(index: 16, name: 'Esther', chapterCount: 10, testament: Testament.old), Book(index: 17, name: 'Job', chapterCount: 42, testament: Testament.old), Book( index: 18, name: 'Psalms', chapterCount: 150, testament: Testament.old, ), Book( index: 19, name: 'Proverbs', chapterCount: 31, testament: Testament.old, ), Book( index: 20, name: 'Ecclesiastes', chapterCount: 12, testament: Testament.old, ), Book( index: 21, name: 'Song of Solomon', chapterCount: 8, testament: Testament.old, ), Book(index: 22, name: 'Isaiah', chapterCount: 66, testament: Testament.old), Book( index: 23, name: 'Jeremiah', chapterCount: 52, testament: Testament.old, ), Book( index: 24, name: 'Lamentations', chapterCount: 5, testament: Testament.old, ), Book( index: 25, name: 'Ezekiel', chapterCount: 48, testament: Testament.old, ), Book(index: 26, name: 'Daniel', chapterCount: 12, testament: Testament.old), Book(index: 27, name: 'Hosea', chapterCount: 14, testament: Testament.old), Book(index: 28, name: 'Joel', chapterCount: 3, testament: Testament.old), Book(index: 29, name: 'Amos', chapterCount: 9, testament: Testament.old), Book(index: 30, name: 'Obadiah', chapterCount: 1, testament: Testament.old), Book(index: 31, name: 'Jonah', chapterCount: 4, testament: Testament.old), Book(index: 32, name: 'Micah', chapterCount: 7, testament: Testament.old), Book(index: 33, name: 'Nahum', chapterCount: 3, testament: Testament.old), Book( index: 34, name: 'Habakkuk', chapterCount: 3, testament: Testament.old, ), Book( index: 35, name: 'Zephaniah', chapterCount: 3, testament: Testament.old, ), Book(index: 36, name: 'Haggai', chapterCount: 2, testament: Testament.old), Book( index: 37, name: 'Zechariah', chapterCount: 14, testament: Testament.old, ), Book(index: 38, name: 'Malachi', chapterCount: 4, testament: Testament.old), Book( index: 39, name: 'Matthew', chapterCount: 28, testament: Testament.newT, ), Book(index: 40, name: 'Mark', chapterCount: 16, testament: Testament.newT), Book(index: 41, name: 'Luke', chapterCount: 24, testament: Testament.newT), Book(index: 42, name: 'John', chapterCount: 21, testament: Testament.newT), Book(index: 43, name: 'Acts', chapterCount: 28, testament: Testament.newT), Book( index: 44, name: 'Romans', chapterCount: 16, testament: Testament.newT, ), Book( index: 45, name: '1 Corinthians', chapterCount: 16, testament: Testament.newT, ), Book( index: 46, name: '2 Corinthians', chapterCount: 13, testament: Testament.newT, ), Book( index: 47, name: 'Galatians', chapterCount: 6, testament: Testament.newT, ), Book( index: 48, name: 'Ephesians', chapterCount: 6, testament: Testament.newT, ), Book( index: 49, name: 'Philippians', chapterCount: 4, testament: Testament.newT, ), Book( index: 50, name: 'Colossians', chapterCount: 4, testament: Testament.newT, ), Book( index: 51, name: '1 Thessalonians', chapterCount: 5, testament: Testament.newT, ), Book( index: 52, name: '2 Thessalonians', chapterCount: 3, testament: Testament.newT, ), Book( index: 53, name: '1 Timothy', chapterCount: 6, testament: Testament.newT, ), Book( index: 54, name: '2 Timothy', chapterCount: 4, testament: Testament.newT, ), Book(index: 55, name: 'Titus', chapterCount: 3, testament: Testament.newT), Book( index: 56, name: 'Philemon', chapterCount: 1, testament: Testament.newT, ), Book( index: 57, name: 'Hebrews', chapterCount: 13, testament: Testament.newT, ), Book(index: 58, name: 'James', chapterCount: 5, testament: Testament.newT), Book( index: 59, name: '1 Peter', chapterCount: 5, testament: Testament.newT, ), Book( index: 60, name: '2 Peter', chapterCount: 3, testament: Testament.newT, ), Book(index: 61, name: '1 John', chapterCount: 5, testament: Testament.newT), Book(index: 62, name: '2 John', chapterCount: 1, testament: Testament.newT), Book(index: 63, name: '3 John', chapterCount: 1, testament: Testament.newT), Book(index: 64, name: 'Jude', chapterCount: 1, testament: Testament.newT), Book( index: 65, name: 'Revelation', chapterCount: 22, testament: Testament.newT, ), ]; static int get totalChapters => books.fold(0, (int sum, Book book) => sum + book.chapterCount); static int get totalBooks => books.length; static int totalChaptersIn(Testament testament) => books .where((Book book) => book.testament == testament) .fold(0, (int sum, Book book) => sum + book.chapterCount); static int totalBooksIn(Testament testament) => books.where((Book book) => book.testament == testament).length; /// Chapter key used to identify a chapter in persisted state. static String chapterKey(int bookIndex, int chapter) => '$bookIndex:$chapter'; }