Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the current directory, in Dart?

Tags:

dart

dart-io

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?

like image 387
Seth Ladd Avatar asked Oct 17 '13 20:10

Seth Ladd


2 Answers

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.

like image 188
Seth Ladd Avatar answered Oct 08 '22 10:10

Seth Ladd


Directory.current.path does it if you want a string, Directory.current for a Directory.

(note: Directory is defined in dart:io)

like image 31
Tree Plate Avatar answered Oct 08 '22 11:10

Tree Plate