WaCron class

A class to manage and run cron jobs using the cron package.

The WaCron class schedules and manages tasks based on the given cron schedule. It includes functionalities for delayed starts, counting executions, and tracking status.

Example:

final cronJob = WaCron(
  schedule: '*/5 * * * * *', // Run every 5 seconds
  onCron: (count, cron) async {
    print('Task executed $count times');
  },
);

cronJob.start();

Constructors

WaCron({required Future onCron(int count, WaCron cron), required String schedule, bool delayFirstMoment = true})
Creates an instance of WaCron.

Properties

counter int
The number of times the cron task has been executed.
no setter
delayFirstMoment bool
Indicates whether the first execution should be delayed.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
onCron Future Function(int count, WaCron cron)
The callback function to be executed on each cron tick.
getter/setter pair
registerTime int
The time the cron was registered (in microseconds since epoch).
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schedule String
Cron schedule in string format.
getter/setter pair
status CronStatus
The current status of the cron job.
no setter

Methods

close() → void
Stops the cron job and cleans up resources.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start() WaCron
Starts the cron job.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

durationToCron(Duration duration) String
Converts a Duration to a cron expression.
evryDay([int day = 1]) String
evryHour([int hour = 1]) String
evryMinute([int min = 1]) String
evryMonth([int month = 1]) String
evrySecond([int sec = 1]) String
evryYear([int year = 1]) String