schedule<T> static method
Schedules task for execution at the specified priority.
Returns a SchedulerTask handle to track completion or cancel the task.
final handle = BloomScheduler.schedule(
() => calculateLayout(),
priority: TaskPriority.userBlocking,
);
Implementation
static SchedulerTask<T> schedule<T>(
FutureOr<T> Function() task, {
TaskPriority priority = TaskPriority.normal,
}) {
final id = ++_nextTaskId;
final taskImpl = _TaskImpl<T>(id, priority, task);
_queues[priority.indexValue].add(taskImpl);
if (_host.isSynchronous || priority == TaskPriority.immediate) {
_flushQueue();
} else {
_requestFlush();
}
return taskImpl;
}