I want to set get image from the camera and set it to the following code:
image: DecorationImage(image: FileImage(file),
So I did this:
File file = await ImagePicker.pickImage(
source: ImageSource.camera,
);
Now above code works fine for now, but 'pickImage' is deprecated and we should use imagePicker.getImage() method instead.
So I used imagePicker.getImage() instead:
PickedFile file = await ImagePicker().getImage(
source: ImageSource.camera,
);
But when I try to set this file to the following image type, it doesn't work
image: DecorationImage(image: FileImage(file),)
How to solve this issue?
Image image = await boundary. toImage(pixelRatio: 3.0); After getting raw image data we convert it to bytecode and after that, we convert the bytecode to Unit8List which we can use to get a base64 string. That's all for today.
You need to use path property of picked file
image: DecorationImage(image: FileImage(File(file.path)),)
If someone might struck on a similar issue
change from pickImage to getImage and still needs a File.
PickedFile selectedFile = await ImagePicker().getImage(source: source);
File selected = File(selectedFile.path);
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