filter method
Filters all MoodleTasks based on the provided criteria.
Returns a list of tasks that match all the specified filters. If no filters are provided, all tasks are returned.
The available filters are:
query: A substring that must be present in the task's name (case-insensitive).courseId: The course ID that the task must belong to.deadlineDiff: The exact difference between the task's deadline and the current time.minDeadlineDiff: The minimum allowed difference between the task's deadline and the current time.maxDeadlineDiff: The maximum allowed difference between the task's deadline and the current time.status: A set of acceptable task statuses. If provided, the task's status must be one of these.type: A set of acceptable task types. If provided, the task's type must be one of these.
If state does not contain data, an empty list is returned.
Implementation
List<MoodleTask> filter({
String? query,
int? courseId,
Set<int>? courseIds,
int? taskId,
Set<int>? taskIds,
Duration? deadlineDiff,
Duration? minDeadlineDiff,
Duration? maxDeadlineDiff,
Set<MoodleTaskStatus> status = const {},
Set<MoodleTaskType> type = const {},
bool Function(MoodleTask)? test,
}) {
if (!state.hasData) return [];
return state.requireData.filter(
query: query,
courseId: courseId,
courseIds: courseIds,
taskId: taskId,
taskIds: taskIds,
deadlineDiff: deadlineDiff,
minDeadlineDiff: minDeadlineDiff,
maxDeadlineDiff: maxDeadlineDiff,
status: status,
type: type,
test: test,
);
}