create method
Creates an alarm. Near the time(s) specified by alarmInfo,
the onAlarm event is fired. If there is another alarm with
the same name (or no name if none is specified), it will be cancelled and
replaced by this alarm.
In order to reduce the load on the user's machine, Chrome limits alarms
to at most once every 30 seconds but may delay them an arbitrary amount
more. That is, setting delayInMinutes or
periodInMinutes to less than 0.5 will not be
honored and will cause a warning. when can be set to less
than 30 seconds after "now" without warning but won't actually cause the
alarm to fire for at least 30 seconds.
To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
|name|: Optional name to identify this alarm. Defaults to the empty
string.
|alarmInfo|: Describes when the alarm should fire. The initial time must
be specified by either when or delayInMinutes (but
not both). If periodInMinutes is set, the alarm will repeat
every periodInMinutes minutes after the initial event. If
neither when or delayInMinutes is set for a
repeating alarm, periodInMinutes is used as the default for
delayInMinutes.
|callback|: Invoked when the alarm has been created.
Implementation
Future<void> create(
String? name,
AlarmCreateInfo alarmInfo,
) async {
await promiseToFuture<void>($js.chrome.alarms.create(
name,
alarmInfo.toJS,
));
}