delayedCall static method

GTween delayedCall(
  1. double delay,
  2. Function callback, {
  3. Object? params,
  4. bool useFrames = false,
})

Similar to Future.delayed, yet GTween.delayedCall runs with the Ticker provider used by GTween, and also allows you to kill the delay in the target Function.

Creates a new GTween instance with a delay before the execution of the specified callback function.

The delay parameter specifies the amount of time (in seconds or frames, depending on the useFrames parameter) before the callback function is executed.

The callback parameter is the function that will be called when the delay expires. It can optionally take parameters, which can be passed using the params parameter.

The useFrames parameter determines whether the delay is specified in seconds (false) or frames (true).

The method returns the created GTween instance.

Implementation

static GTween delayedCall(
  double delay,
  Function callback, {
  Object? params,
  bool useFrames = false,
}) {
  var props = GVars()
    ..delay = delay
    ..useFrames = useFrames
    ..onComplete = callback
    ..onCompleteParams = CallbackParams.parse(params);
  return GTween(
    callback,
    0,
    {},
    props,
  );
}