dirName property

String get dirName

Gets the part of path before the last separator.

File().dirname('path/to/foo.dart'); // -> 'path/to'
Directory('path/to').dirName;          // -> 'path'

Trailing separators are ignored.

Directory('path/to/').dirName; // -> 'path'

If an absolute path contains no directories, only a root, then the root is returned.

Directory('/').dirName;  // -> '/' (posix)
Directory('c:\').dirName;  // -> 'c:\' (windows)

If a relative path has no directories, then '.' is returned.

Directory('foo').dirName;  // -> '.'
Directory('').dirName;  // -> '.'

Implementation

String get dirName => path_helper.dirname(path);