Refactor chapter seeking logic in AudiobookPlayerSeekChapterButton

This commit is contained in:
Dr-Blank 2024-05-21 10:50:02 -04:00
parent aefe5299ca
commit 73e8f4bfa6
No known key found for this signature in database
GPG key ID: 7452CC63F210A266
7 changed files with 217 additions and 96 deletions

View file

@ -225,6 +225,10 @@ class AudiobookPlayer extends AudioPlayer {
if (_book == null) {
return null;
}
// if the list is empty, return null
if (_book!.chapters.isEmpty) {
return null;
}
return _book!.chapters.firstWhere(
(element) {
return element.start <= positionInBook && element.end >= positionInBook;