clock method

Stream<int> clock()

Stream of moment delayed with 1 second.

Can be used to create realtime clock or time counter.

Implementation

Stream<int> clock() async* {
  while (true) {
    await Future.delayed(const Duration(seconds: 1));
    yield DateTime.now().millisecondsSinceEpoch;
  }
}