normalPath function
path with / between parts and no trailing / (a drive root such as
C:/ keeps its own).
Implementation
String normalPath(String path) {
var p = path.replaceAll(r'\', '/');
while (p.length > 1 && p.endsWith('/') && !p.endsWith(':/')) {
p = p.substring(0, p.length - 1);
}
return p;
}