#Flutter Tutorial – Save Selected Image in App Directory in separate Thread (coderzheaven.com)

0 19

#Flutter Tutorial – Save Selected Image in App Directory in separate Thread (coderzheaven.com)

In this article, we will how to select an image by capturing from camera or gallery, then we will save the image in app’s temporary directory in a separate thread and then load it from there.
For this demo we need three packages.

Add Dependencies
Open pubspec.yaml file and then add the below dependencies.
path_provider: ^1.6.9
image_picker: ^0.6.7
image: ^2.1.4
path_provider for getting access to the app’s directory.
image_picker for open camera or gallery and get the image.
image for encoding and decoding the image.
Make the following changes in your Android and iOS project.

iOS
Add the following keys to your Info.plist file, located in project root/ios/Runner/Info.plist:
NSPhotoLibraryUsageDescription – describe why your app needs permission for the photo library. This is called Privacy – Photo Library Usage Description in the visual editor.
NSCameraUsageDescription – describe why your app needs access to the camera. This is called Privacy – Camera Usage Description in the visual editor.
NSMicrophoneUsageDescription – describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy – Microphone Usage Description in the visual editor.

Android
API 29+
No configuration required - the plugin should work out of the box.
API less than 29
Add android:requestLegacyExternalStorage=”true” as an attribute to the application tag in AndroidManifest.xml. The attribute is false by default on apps targeting Android Q.

Medium Article Link:
https://medium.com/@vipinvijayan23/select-image-from-camera-gallery-save-image-in-apps-directory-in-separate-thread-load-image-47b0c9eaab3f

Article Link:
http://www.coderzheaven.com/2020/06/07/select-image-from-camera-gallery-save-image-in-apps-directory-in-separate-thread-load-image-from-apps-directory-to-ui/

Source Code
https://bitbucket.org/vipinvijayan1987/tutorialprojects/src/ImageSelectionAndSaveToDiskPerformance/

Source

Leave A Reply

Your email address will not be published.