normalizeURI static method
Normalizes the passed URI.
Implementation
static String normalizeURI(String uri) {
if (uri.startsWith(_kAssetScheme)) {
// Handle asset:// scheme. Only for Flutter.
return AssetLoader.load(uri);
}
// content:// URI support for Android.
try {
if (Platform.isAndroid) {
if (Uri.parse(uri).isScheme('CONTENT')) {
final fd = AndroidContentUriProvider.openFileDescriptorSync(uri);
if (fd > 0) {
return 'fd://$fd';
}
}
}
} catch (exception, stacktrace) {
print(exception);
print(stacktrace);
}
// Keep the resulting URI normalization same as used by libmpv internally.
// [File] or network URIs.
final parser = URIParser(uri);
switch (parser.type) {
case URIType.file:
{
return parser.file!.path;
}
case URIType.network:
{
return parser.uri!.toString();
}
default:
return uri;
}
}