diff --git a/lib/scheduler_core.dart b/lib/scheduler_core.dart index f00abc7..301550e 100644 --- a/lib/scheduler_core.dart +++ b/lib/scheduler_core.dart @@ -1,7 +1,6 @@ -/// Public exports for the ADHD scheduling core. -/// -/// Keep this file small. Implementation details belong in `lib/src/`. -library adhd_scheduler_core; +// Public exports for the ADHD scheduling core. +// +// Keep this file small. Implementation details belong in `lib/src/`. export 'src/models.dart'; export 'src/scheduling_engine.dart'; diff --git a/lib/src/models.dart b/lib/src/models.dart index 22f5a57..d168ae9 100644 --- a/lib/src/models.dart +++ b/lib/src/models.dart @@ -181,7 +181,8 @@ class Task { final TaskStatistics stats; bool get isFlexible => type == TaskType.flexible; - bool get isRequiredVisible => type == TaskType.critical || type == TaskType.inflexible; + bool get isRequiredVisible => + type == TaskType.critical || type == TaskType.inflexible; bool get isLocked => type == TaskType.locked; bool get isBacklog => status == TaskStatus.backlog; @@ -213,7 +214,8 @@ class Task { reward: reward ?? this.reward, difficulty: difficulty ?? this.difficulty, durationMinutes: durationMinutes ?? this.durationMinutes, - scheduledStart: clearSchedule ? null : (scheduledStart ?? this.scheduledStart), + scheduledStart: + clearSchedule ? null : (scheduledStart ?? this.scheduledStart), scheduledEnd: clearSchedule ? null : (scheduledEnd ?? this.scheduledEnd), parentTaskId: parentTaskId ?? this.parentTaskId, createdAt: createdAt ?? this.createdAt, @@ -286,7 +288,7 @@ class TimeInterval { required this.start, required this.end, this.label, - }) : assert(!end.isBefore(start), 'end must not be before start'); + }); final DateTime start; final DateTime end; diff --git a/lib/src/scheduling_engine.dart b/lib/src/scheduling_engine.dart index 62e948b..8b399a4 100644 --- a/lib/src/scheduling_engine.dart +++ b/lib/src/scheduling_engine.dart @@ -23,7 +23,7 @@ class SchedulingWindow { const SchedulingWindow({ required this.start, required this.end, - }) : assert(!end.isBefore(start), 'end must not be before start'); + }); final DateTime start; final DateTime end; @@ -63,7 +63,9 @@ class SchedulingInput { } List get requiredVisibleTasks { - return tasks.where((task) => task.isRequiredVisible).toList(growable: false); + return tasks + .where((task) => task.isRequiredVisible) + .toList(growable: false); } List get flexibleIntervals { @@ -312,7 +314,8 @@ class SchedulingEngine { required Duration duration, required List blocked, }) { - final sortedBlocked = [...blocked]..sort((a, b) => a.start.compareTo(b.start)); + final sortedBlocked = [...blocked] + ..sort((a, b) => a.start.compareTo(b.start)); var cursor = windowStart; for (final interval in sortedBlocked) { @@ -327,7 +330,8 @@ class SchedulingEngine { } final candidateEnd = cursor.add(duration); - if (candidateEnd.isBefore(windowEnd) || candidateEnd.isAtSameMomentAs(windowEnd)) { + if (candidateEnd.isBefore(windowEnd) || + candidateEnd.isAtSameMomentAs(windowEnd)) { return TimeInterval(start: cursor, end: candidateEnd); } @@ -420,8 +424,7 @@ _BacklogInsertionPlan? _planBacklogInsertion({ } final startsBeforeWindow = interval.start.isBefore(input.window.start); - final startsAfterWindow = - interval.start.isAfter(input.window.end) || + final startsAfterWindow = interval.start.isAfter(input.window.end) || interval.start.isAtSameMomentAs(input.window.end); if (startsBeforeWindow || startsAfterWindow) {