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.
Permissions are the way to interact application to mobile phone user to access a specific type of data. For example If want to access User Location in our android application then we must have to add the Access Location Permission in our flutter android project’s AndroidManifest.xml file.
Flutter is an awesome toolkit. It allows us for fast UI iteration. But what if we are not able to access the storage of the device we’re running on? In this guide, we’ll go through how we can get the storage permission in a Flutter Application. For this guide, I assume you’re using an Android Device.
Another way to access storage using permission_handler package 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.
This Permission handler plugin for Flutter is developed by Baseflow. You can contact us at [email protected]
Have you added the below code to android manifest file?
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With