I want to know what the current directory is. I don't want to shell out to run pwd
. Is there an easy way to do this in Dart?
Indeed there is!
import 'dart:io';
main() {
Directory current = Directory.current;
}
Note: this only works on the command-line, not in the browser.
Read more about the API docs for Directory.current.
Directory.current.path
does it if you want a string, Directory.current
for a Directory.
(note: Directory
is defined in dart:io
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With