relative static method
Implementation
static String relative(String path, Uri to) {
var fileUri = Uri.parse(path);
var libName = to.pathSegments.first;
if ((to.scheme == 'package' &&
fileUri.scheme == 'package' &&
fileUri.pathSegments.first == libName) ||
(to.scheme == 'asset' && fileUri.scheme != 'package')) {
if (fileUri.path == to.path) {
return fileUri.pathSegments.last;
} else {
return p.posix
.relative(fileUri.path, from: to.path)
.replaceFirst('../', '');
}
} else {
return path;
}
}