{"id":1838,"date":"2024-03-18T08:52:14","date_gmt":"2024-03-18T08:52:14","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=1838"},"modified":"2024-03-29T08:55:20","modified_gmt":"2024-03-29T08:55:20","slug":"platformexception-read_external_storage_denied-in-flutter","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/platformexception-read_external_storage_denied-in-flutter\/","title":{"rendered":"PlatformException: read_external_storage_denied in Flutter"},"content":{"rendered":"\n<p><strong>Error:<\/strong> PlatformException(read_external_storage_denied, User did not allow reading external storage, null, null)<\/p>\n\n\n\n<p>Encountering a PlatformException with the message &#8220;read_external_storage_denied&#8221; indicates that the application is attempting to access external storage without the necessary permissions granted by the user. Here&#8217;s how to resolve this issue:<\/p>\n\n\n\n<p><strong>1. Request Permission:<\/strong> Before accessing external storage, ensure that your app requests the required permissions from the user. Use the <code>permission_handler<\/code> package to handle permission requests in Flutter. Here&#8217;s how you can implement it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:permission_handler\/permission_handler.dart';\r\n\r\n\/\/ Requesting permission\r\nPermissionStatus status = await Permission.storage.request();\r\nif (status.isGranted) {\r\n  \/\/ Proceed with accessing external storage\r\n} else {\r\n  \/\/ Handle denied or restricted permissions\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>Ensure that the necessary permission declarations are within the <code>&lt;manifest&gt;<\/code> tag in your AndroidManifest.xml file.<\/p>\n\n\n\n<p><strong>2. Check Flutter Version:<\/strong> Ensure that both the <code>file_picker<\/code> package and the Flutter framework are up to date. Older versions may not be compatible with newer ones. Update the <code>file_picker<\/code> dependency in your pubspec.yaml file to the latest version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dependencies:\r\n  file_picker: ^4.2.0  # or the latest version\r<\/code><\/pre>\n\n\n\n<p>Run <code>flutter pub get<\/code> to fetch the updated dependencies.<\/p>\n\n\n\n<p><strong>3. Test on Real Device:<\/strong> Emulators may sometimes behave differently from real devices, especially concerning permission-related issues. To accurately simulate user interactions, test your app on a real device.<\/p>\n\n\n\n<p><strong>4. Reinstall the App:<\/strong> Consider uninstalling and reinstalling the app on the device if you&#8217;ve made changes to its dependencies or permissions. This ensures that any modifications take effect properly.<\/p>\n\n\n\n<p>By following these steps, you can resolve the PlatformException related to &#8220;read_external_storage_denied&#8221; and ensure that your Flutter app can access external storage with the necessary permissions granted by the user.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Error: PlatformException(read_external_storage_denied, User did not allow reading external storage, null, null) Encountering a PlatformException with the message &#8220;read_external_storage_denied&#8221; indicates that the application is attempting to access external&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1307,1303,1304,1305,1299,1301,1302,1300,1306],"class_list":["post-1838","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-app-installation","tag-external-storage-access","tag-file_picker-package","tag-flutter-dependencies","tag-flutter-troubleshooting","tag-permission-handling","tag-permission_handler-package","tag-platformexception","tag-real-device-testing"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=1838"}],"version-history":[{"count":2,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1838\/revisions"}],"predecessor-version":[{"id":1840,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1838\/revisions\/1840"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=1838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=1838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=1838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}