When using image_picker in its latest version, as follows:
final XFile? pickedFile = await picker.pickImage(
source: ImageSource.camera,
maxHeight: 150,
imageQuality: 90,
);
I return the path as I have found in some examples that I have reviewed, I take the image with the camera and with the following part:
File file = File(pickedFile!.path);
print('Ruta de archivo = ' + file.toString());
I look for the path where the image is located and I get the following message in the console:
Ruta de archivo = File: '/data/user/0/com.example.qrcode/cache/scaled_bb1c9502-5b0c-4afd-bfcd-99115bcf788a3760710577154129314.jpg'
I understand that if you get the path you can convert the image since it was located in cache but when I get the path, I pass it to byte like this:
List<int> fileInByte = file.readAsBytesSync();
String fileInBase64 = base64Encode(fileInByte);
print(fileInBase64);
In console it looks like this:
But if I take the whole line and add data:image/jpeg;base64, plus the line of code in base64 something comes out, you don't see the image, you only see a somewhat small box, I don't know what it could be since it doesn't convert the image as it should be
I already saw the problem, your code is correct, but when you try to display the image in base64, the console does not show you the complete information due to the limitations of the
print
.Do it using the method
log
, but you need to import this:Then you use the
log