I need to get all the images from a gallery without using image_picker or other packages in flutter.
I tried using image_picker. But it turned out that it cannot be used. And how after receiving the images to display a preview of the selected image?
2
Answers
You can look at how
image_picker
works under the hood, and inspect its native implementation to determine the native methods you may be able to use.https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker
See this page on how to run native code in your Flutter app (which you can also do without using a package):
https://docs.flutter.dev/platform-integration/platform-channels
The question is, why are you unable to use packages? They should be easy to include via pub.dev or even as a local dependency in your
pubspec.yaml
if the former does not work.To show the preview, I know
image_picker
copies the file to the app’s temporary directory (which you can get usinggetTemporaryDirectory()
with path_provider), after which you can show anImage.file
in your app as the preview.Yes you can do it. look at bellow code segment.
1.First you should make varible As
File
type.2.Then you should make a method for select image.like bellow,
3.Now you can access images like bellow code.
Full code part
**If you want to use filepicker try bellow steps,
1.You should add some packages before use this method,
you can get it by using this link
now you can import it like this import
'package:file_picker/file_picker.dart';
try like this you can now fix you’r issue.