Clone this repo:
  1. daf0fad Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (#60) by dependabot[bot] · 8 weeks ago master
  2. f975668 Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#59) by dependabot[bot] · 5 months ago
  3. eb5d2f5 Bump actions/checkout from 4.1.0 to 4.1.1 (#58) by dependabot[bot] · 5 months ago
  4. 200a020 Bump actions/checkout from 3.6.0 to 4.1.0 (#56) by dependabot[bot] · 6 months ago
  5. 8a2b550 Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#57) by dependabot[bot] · 6 months ago

Dart CI pub package package publisher

This package provides a Clock class which encapsulates the notion of the “current time” and provides easy access to points relative to the current time. Different Clocks can have a different notion of the current time, and the default top-level clock's notion can be swapped out to reliably test timing-dependent code.

For example, you can use clock in your libraries like this:

// run_with_timing.dart
import 'package:clock/clock.dart';

/// Runs [callback] and prints how long it took.
T runWithTiming<T>(T Function() callback) {
  var stopwatch = clock.stopwatch()..start();
  var result = callback();
  print('It took ${stopwatch.elapsed}!');
  return result;
}

...and then test your code using the fake_async package, which automatically overrides the current clock:

// run_with_timing_test.dart
import 'run_with_timing.dart';

import 'package:fake_async/fake_async.dart';
import 'package:test/test.dart';

void main() {
  test('runWithTiming() prints the elapsed time', () {
    FakeAsync().run((async) {
      expect(() {
        runWithTiming(() {
          async.elapse(Duration(seconds: 10));
        });
      }, prints('It took 0:00:10.000000!'));
    });
  });
}