withClock<T> function

T withClock <T>(
  1. Clock clock,
  2. T callback(
    1. {@deprecated bool isFinal: false}

    Runs callback with the given value for the top-level clock field.

    This is Zone-scoped, so asynchronous callbacks spawned within callback will also use the new value for clock.

    If isFinal is true, calls to withClock within callback will throw a StateError. However, this parameter is deprecated and should be avoided.


    T withClock<T>(Clock clock, T callback(), {@deprecated bool isFinal: false}) {
      if (Zone.current[_isFinalKey] ?? false) {
        throw new StateError(
            "Cannot call withClock() within a call to withClock(isFinal: true).");
      return runZoned(callback,
          zoneValues: {_clockKey: clock, _isFinalKey: isFinal});