split function

List<String> split(
  1. String path
)

Splits path into its components using the current platform's separator.

p.split('path/to/foo'); // -> ['path', 'to', 'foo']

The path will not be normalized before splitting.

p.split('path/../foo'); // -> ['path', '..', 'foo']

If path is absolute, the root directory will be the first element in the array. Example:

// Unix
p.split('/path/to/foo'); // -> ['/', 'path', 'to', 'foo']

// Windows
p.split(r'C:\path\to\foo'); // -> [r'C:\', 'path', 'to', 'foo']
p.split(r'\\server\share\path\to\foo');
  // -> [r'\\server\share', 'foo', 'bar', 'baz']

// Browser
p.split('https://dart.cn/path/to/foo');
  // -> ['https://dart.cn', 'path', 'to', 'foo']

Implementation

List<String> split(String path) => context.split(path);