split method
Splits path
into its components using the current platform's
separator. Example:
context.split('path/to/foo'); // -> ['path', 'to', 'foo']
The path will not be normalized before splitting.
context.split('path/../foo'); // -> ['path', '..', 'foo']
If path
is absolute, the root directory will be the first element in the
array. Example:
// Unix
context.split('/path/to/foo'); // -> ['/', 'path', 'to', 'foo']
// Windows
context.split(r'C:\path\to\foo'); // -> [r'C:\', 'path', 'to', 'foo']
Implementation
List<String> split(String path) {
var parsed = _parse(path);
// Filter out empty parts that exist due to multiple separators in a row.
parsed.parts = parsed.parts.where((part) => !part.isEmpty).toList();
if (parsed.root != null) parsed.parts.insert(0, parsed.root);
return parsed.parts;
}