I'm trying to save an image to phone local directory. Here I use image_downloader package for that. Here's my code
class DownloadImage {
Future writeToDownloadPath(GridImage imageData) async {
try {
var imageId = await ImageDownloader.downloadImage(imageData.url
,destination: AndroidDestinationType.custom(directory: 'motivational Quotes',
inPublicDir: true ,subDirectory: '/motivational Quotes${imageData.location}'));
print('imageId' + imageId.toString());
if (imageId == null) {
return;
}
} catch(e) {
print(e.toString());
}
}
}
When I run on Android 10 device and try to download an image it gives me this error,
E/MethodChannel#plugins.ko2ic.com/image_downloader(25282): java.lang.IllegalStateException: Not one of standard directories: motivational Quotes
I already added android:requestLegacyExternalStorage="true" in AndroidManifest and set targetSdkVersion and compileSdkVersion to 29 in build.gradle file. I did flutter clean and run the code but issue remain the same.
build.gradle
defaultConfig {
applicationId "com.example.app
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
AndroidManifest
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Motivational Quotes"
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true">
I would be really grateful if anyone can help me with this issue. Thanks !
There are only 4 standard directories in this package.
So, you have to change here:
I advise you to keep it simple like this: