Skip to content

CronScheduledTrigger

A trigger that triggers based on a cron job specification.

Based on the cron package. See crontab guru for a useful tool for specifying cron jobs.

Inheritance
Implemented types
Annotations

Constructors

CronScheduledTrigger.fromJson

CronScheduledTrigger.fromJson(
  1. Map<String, dynamic> json
)

CronScheduledTrigger

CronScheduledTrigger({
  1. int? minute,
  2. int? hour,
  3. int? day,
  4. int? month,
  5. int? weekday,
})

Creates a cron scheduled trigger based on specifying:

  • minute - The minute to trigger. int 0-59 or null (= match all).
  • hour - The hour to trigger. int 0-23 or null (= match all).
  • day - The day of the month to trigger. int 1-31 or null (= match all).
  • month - The month to trigger. int 1-12 or null (= match all).
  • weekday - The week day to trigger. int 0-6 or null (= match all).

CronScheduledTrigger.parse

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

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

  • cronExpression - The cron expression as a String.
  • duration - Not used.

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.

Properties

cronExpression

String cronExpression
getter/setter pair

The cron expression, in the format <minutes> <hours> <days> <months> <weekdays>.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

Methods

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.