diff --git a/mobile/lib/playback.dart b/mobile/lib/playback.dart index d169b6a..f257eea 100644 --- a/mobile/lib/playback.dart +++ b/mobile/lib/playback.dart @@ -341,8 +341,10 @@ class _PlaybackService extends BackgroundAudioTask { if (partIds.isNotEmpty) { subtitleBuffer.write(': '); - final section = - workInfo.sections.lastWhere((s) => s.beforePartIndex <= partIds[0]); + final section = workInfo.sections.lastWhere( + (s) => s.beforePartIndex <= partIds[0], + orElse: () => null, + ); if (section != null) { subtitleBuffer.write(section.title); diff --git a/mobile/lib/screens/program.dart b/mobile/lib/screens/program.dart index fe6bad4..9a3d170 100644 --- a/mobile/lib/screens/program.dart +++ b/mobile/lib/screens/program.dart @@ -100,6 +100,7 @@ class _ProgramScreenState extends State { if (recordingInfo.recording.work != lastWorkId) { lastWorkId = recordingInfo.recording.work; workInfo = await backend.db.getWork(lastWorkId); + lastSectionIndex = null; } children.addAll([ @@ -118,7 +119,7 @@ class _ProgramScreenState extends State { final sectionIndex = workInfo.sections .lastIndexWhere((s) => s.beforePartIndex <= partId); - if (sectionIndex != lastSectionIndex) { + if (sectionIndex != lastSectionIndex && sectionIndex >= 0) { lastSectionIndex = sectionIndex; children.add(Padding( padding: const EdgeInsets.only( diff --git a/mobile/lib/widgets/player_bar.dart b/mobile/lib/widgets/player_bar.dart index 76694d7..055c9fc 100644 --- a/mobile/lib/widgets/player_bar.dart +++ b/mobile/lib/widgets/player_bar.dart @@ -62,9 +62,11 @@ class _PlayerBarState extends State { if (_partIds.isNotEmpty) { subtitleBuffer.write(': '); - final section = _workInfo.sections - .lastWhere((s) => s.beforePartIndex <= _partIds[0]); - + final section = _workInfo.sections.lastWhere( + (s) => s.beforePartIndex <= _partIds[0], + orElse: () => null, + ); + if (section != null) { subtitleBuffer.write(section.title); subtitleBuffer.write(': ');