CronSchedule class
Cron-style scheduling for periodic tasks.
Supports standard 5-field cron expressions:
minute hour day-of-month month day-of-week
Examples:
- "0 9 * * MON" → Every Monday at 9:00 AM
- "0 */6 * * *" → Every 6 hours
- "0 0 1 * *" → First day of every month at midnight
- "*/15 * * * *" → Every 15 minutes
- "0 9-17 * * 1-5" → Every hour from 9am-5pm on weekdays
Field meanings:
- Minute (0-59)
- Hour (0-23)
- Day of month (1-31)
- Month (1-12 or JAN-DEC)
- Day of week (0-6 where 0=Sunday, or SUN-SAT)
Special characters:
*= any value,= multiple values (e.g., MON,WED,FRI)-= range (e.g., 9-17)/= step (e.g., */5 = every 5 units)
Constructors
- CronSchedule(String expression)
-
const
- CronSchedule.dailyAt({required int hour, int minute = 0})
-
Builder: At specific time daily
Example:
CronSchedule.dailyAt(hour: 9, minute: 30)→ 9:30 AM dailyfactory - CronSchedule.everyNHours(int hours)
-
Builder: Every N hours
Example:
CronSchedule.everyNHours(6)→ Every 6 hoursfactory - CronSchedule.everyNMinutes(int minutes)
-
Builder: Every N minutes
Example:
CronSchedule.everyNMinutes(5)→ Every 5 minutesfactory - CronSchedule.monthlyAt({required int day, required int hour, int minute = 0})
-
Builder: Monthly at specific date and time
Example:
CronSchedule.monthlyAt(day: 1, hour: 9)→ 1st of month at 9 AMfactory -
CronSchedule.onDaysAt({required List<
String> days, required int hour, int minute = 0}) -
Builder: Specific days at specific time
Example:
CronSchedule.onDaysAt(days: ['MON', 'WED', 'FRI'], hour: 9)→ 9 AM on Mon/Wed/Frifactory - CronSchedule.weekdaysAt({required int hour, int minute = 0})
-
Builder: Weekdays at specific time
Example:
CronSchedule.weekdaysAt(hour: 9)→ 9 AM Mon-Frifactory - CronSchedule.weekendAt({required int hour, int minute = 0})
-
Builder: Weekends at specific time
Example:
CronSchedule.weekendAt(hour: 10)→ 10 AM on Sat/Sunfactory
Properties
- expression → String
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
isValid(
) → bool - Parse and validate cron expression
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- daily → const CronSchedule
- dailyAt9am → const CronSchedule
- every5Minutes → const CronSchedule
- every15Minutes → const CronSchedule
- every30Minutes → const CronSchedule
- everyMinute → const CronSchedule
- Common presets
- hourly → const CronSchedule
- monthly → const CronSchedule
- weeklyMonday → const CronSchedule