call method

void call(
  1. VoidCallback action, {
  2. bool immediateCall = true,
})

Executes the provided action, adhering to the throttling interval.

If no action is currently in progress, the action will execute immediately if immediateCall is true (default). Otherwise, the action will be executed after the throttling interval.

Parameters

  • action: The action to be throttled and executed.
  • immediateCall: If true, executes the action immediately if no timer is active.

Implementation

void call(VoidCallback action, {bool immediateCall = true}) {
  _action = action;

  if (_timer == null) {
    if (immediateCall) {
      _callAction();
    }

    _timer = Timer(interval, _callAction);
  }
}