1

I was searching for sleep method in Flutter/Dart and I found this:

https://api.dart.dev/stable/2.9.2/dart-io/sleep.html

But I can't get it to work because it errors: Undefined name '_ProcessUtils'

I know I can use Future.delayed or just use Animations, but I'm just curious about _ProcessUtils.

Shayan
  • 709
  • 1
  • 15
  • 31

1 Answers1

2

Dart uses a leading underscore in an identifier to mark members and top-level declarations as private.

_ProcessUtils is a private class that is not accessible to you. You should not need it. It's the implementation, not an example.

Just call sleep() with your duration.

Read more about Libraries and Visibility

void
  • 12,787
  • 3
  • 28
  • 42
nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Thanks, this works on Flutter: `sleep(Duration(seconds: 1));` But it seems Dart does not have the `sleep()` function, this: `sleep(100)` does not work for example on https://dartpad.dartlang.org/ – Shayan Sep 13 '20 at 14:45
  • 1
    You would need to `import 'dart.io'` and that does not work on the web. – nvoigt Sep 13 '20 at 14:56