Функция sleep
- Duration duration
Засыпает на указанный срок в duration.
Используйте с осторожностью, так как в изолированном потоке нельзя обработать асинхронные операции во время блокировки в вызове sleep.
var duration = const Duration(seconds: 5);
print('Start sleeping');
sleep(duration);
print('5 seconds has passed'); Реализация
void sleep(Duration duration) {
int milliseconds = duration.inMilliseconds;
if (milliseconds < 0) {
throw new ArgumentError("sleep: duration cannot be negative");
}
if (!_EmbedderConfig._maySleep) {
throw new UnsupportedError(
"This embedder disallows calling dart:io's sleep()");
}
_ProcessUtils._sleep(milliseconds);
}
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-io/sleep.html