getExternalStorageWithoutDataDir function
This function aims to get path like: /storage/emulated/0/
not like /storage/emulated/0/Android/data/package.name.example/files
Implementation
Future<Directory> getExternalStorageWithoutDataDir(
String unfilteredPath) async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
print("storage_helper->getExternalStorageWithoutDataDir: " +
packageInfo.packageName);
String subPath =
pathlib.join("Android", "data", packageInfo.packageName, "files");
if (unfilteredPath.contains(subPath)) {
String filteredPath = unfilteredPath.split(subPath).first;
print("storage_helper->getExternalStorageWithoutDataDir: " + filteredPath);
return Directory(filteredPath);
} else {
return Directory(unfilteredPath);
}
}