Spec-Zone.ru › Dart 2

dart:async

Конструктор Timer

Timer(
  1. Duration duration,
  2. void callback( )
)

Создает новый таймер.

Функция callback вызывается после указанной duration.

Пример:

final timer =
    Timer(const Duration(seconds: 5), () => print('Timer finished'));
// Outputs after 5 seconds: "Timer finished".

Реализация

factory Timer(Duration duration, void Function() callback) {
  if (Zone.current == Zone.root) {
    // No need to bind the callback. We know that the root's timer will
    // be invoked in the root zone.
    return Zone.current.createTimer(duration, callback);
  }
  return Zone.current
      .createTimer(duration, Zone.current.bindCallbackGuarded(callback));
}

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-async/Timer/Timer.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API