firka_wear: fix RangeError in home_screen substring

Closes: #14
This commit is contained in:
2026-03-05 13:28:33 +01:00
parent 0675a5109a
commit 4ecf0d1a3f

View File

@@ -296,10 +296,10 @@ class _WearHomeScreenState extends State<WearHomeScreen> {
if (nextLessonText.length > 10) {
if (nextLesson.roomName!.length > 10) {
nextLessonText =
"${nextLesson.name}, ${nextLesson.roomName!.substring(0, 6)}...";
"${nextLesson.name}, ${nextLesson.roomName!.substring(0, min(6, nextLesson.roomName!.length))}...";
} else {
nextLessonText =
"${nextLesson.name.substring(0, 10)}..., ${nextLesson.roomName}";
"${nextLesson.name.substring(0, min(10, nextLesson.name.length))}..., ${nextLesson.roomName}";
}
}
@@ -320,11 +320,12 @@ class _WearHomeScreenState extends State<WearHomeScreen> {
"${currentLesson.name}, ${currentLesson.roomName}";
if (currentLessonText.length > 10) {
if (currentLesson.roomName!.length > 10) {
final room = currentLesson.roomName!;
currentLessonText =
"${currentLesson.name}, ${currentLesson.roomName?.substring(0, 6) ?? ''}...";
"${currentLesson.name}, ${room.substring(0, min(6, room.length))}...";
} else {
currentLessonText =
"${currentLesson.name.substring(0, 10)}..., ${currentLesson.roomName}";
"${currentLesson.name.substring(0, min(10, currentLesson.name.length))}..., ${currentLesson.roomName}";
}
}