Reputation: 487
I am trying to get storage permission in the initstate()
function of the class.I used two packages - Simple_Permissions
and Permission
package. But both give the same error to me.
FYI - I have put the permission in manifest already.
"E/SimplePermission( 6405): set to never ask againandroid.permission.WRITE_EXTERNAL_STORAGE I/SimplePermission( 6405): Requesting permission status : 4 I/flutter ( 6405): permission request result is PermissionStatus.deniedNeverAsk"
What I understood from this is that this error should come if the permission was set to "never ask again" by the user . But it is the first time I am requesting storage permission in my app .
What I have tried:
Also:
I request 2 permissions in my app, one for location and other for writing storage.
When I go to the settings --> installed apps --> permissions --> I CAN see the permission for location and I can turn it on/off. But I CANNOT see permission for storage.
Upvotes: 9
Views: 33971
Reputation: 34170
Another way to access storage using permission_handler
package
dependencies:
permission_handler: ^5.0.1
Code Snippet
status.isUndetermined is used to determine whether we had asked for permission yet or not.
var status = await Permission.storage.status;
if (status.isUndetermined) {
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.storage,
Permission.camera,
].request();
print(statuses[Permission.storage]); // it should print PermissionStatus.granted
}
Note: Don't forget to add permission in AndroidMenifest for android & info.plist for iOS.
Upvotes: 4
Reputation: 5351
Have you added the below code to android manifest file?
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
Upvotes: 4
Reputation: 5859
This may be happening because another plugin is setting android:maxSdkVersion attribute on your WRITE_EXTERNAL_STORAGE declaration in the AndroidManifest.xml Try replacing the line in AndroidManifest.xml with:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion"/>
This fixed the issue for me.
Upvotes: 3