isPathAbsolute function
Whether path is absolute — starts with / or has a drive letter (C:).
Both / and \ are accepted as separators.
Example:
isPathAbsolute('/etc/hosts'); // true
isPathAbsolute(r'C:\Windows'); // true
isPathAbsolute('docs/readme.md'); // false
Implementation
bool isPathAbsolute(String path) {
final String p = path.replaceAll(r'\', '/');
return p.startsWith('/') || (p.length >= 2 && p[1] == ':');
}