rootPrefix function Null safety

String rootPrefix(
  1. String path
)

Returns the root of path, if it's absolute, or the empty string if it's relative.

// Unix
p.rootPrefix('path/to/foo'); // -> ''
p.rootPrefix('/path/to/foo'); // -> '/'

// Windows
p.rootPrefix(r'path\to\foo'); // -> ''
p.rootPrefix(r'C:\path\to\foo'); // -> r'C:\'
p.rootPrefix(r'\\server\share\a\b'); // -> r'\\server\share'

// URL
p.rootPrefix('path/to/foo'); // -> ''
p.rootPrefix('https://dart.dev/path/to/foo');
  // -> 'https://dart.dev'

Implementation

String rootPrefix(String path) => context.rootPrefix(path);