Buscar pacotes, repositórios e categorias de apps

Repositório GitHubdart-archive/clock

relógio

Um invólucro falsificável para as APIs de relógio do dart:core.

Capa do projeto relógio
Estrelas
41
Forks
16
Último push (UTC)
28 de out. de 2024
Status do projeto
Arquivado

README original

Texto original em inglês. Visite o GitHub para a versão atual.

[!IMPORTANT]
This repo has moved to https://github.com/dart-lang/tools/tree/main/pkgs/clock

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!'));
    });
  });
}
Dart Archive GitHub avatar
Autor no GitHub

Dart Archive ↗

Legacy projects kept around for posterity – See github.com/dart-lang for current work

LinguagensDart

Dependências usadas

Lista de dependências 2 itens

  • dart_flutter_team_lintsDesenvolvimento^3.0.0
  • testDesenvolvimento^1.16.6

Como escolher um repositório para seu projeto?

Filtre pelo caso de uso, compare a atividade e confira o projeto original antes de adotá-lo.

  1. Busque por nome, autor ou descrição e filtre por tema.
  2. Compare estrelas, forks e envios recentes. Estrelas indicam interesse, mas não garantem qualidade.
  3. Confira o README, a licença e as issues no GitHub antes de usar o projeto.

Fontes e manutenção

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗