CronScheduledTrigger.parse constructor

CronScheduledTrigger.parse({
  1. required String cronExpression,
  2. Duration? duration,
})

Create a CronScheduledTrigger based on a cron-formatted string expression.

  • cronExpression - The cron expression as a String.
  • duration - The duration (until stopped) of the the sampling.

Cron format used is:

<minutes> <hours> <days> <months> <weekdays>

For example:

  • 42 19 * * * is "Everyday at 19:42".
  • 0 9 * * 1 is "Every Monday at 09:00".
  • 0 0 1 * * is "The first day of every month at midnight".

Note the following:

  • the fields are separated by spaces
  • that * is used to signify "match all"
  • that the weekday field uses 0 for Sunday
  • that the number fields are numbered from 0 (minutes, weekdays) or 1 (hours, days, months)
  • that numbers are single values - ranges and lists are not supported
  • that number are to be stated as integers, and not a string with leading zeros (e.g., use 9 and not 09 for 9 o'clock)

See e.g. crontab guru for help in formatting cron jobs.

Implementation

factory CronScheduledTrigger.parse({
  required String cronExpression,
  Duration? duration,
}) => CronScheduledTrigger._(cronExpression: cronExpression);