I am actually trying to convert an image picked by ImagePicker
in flutter to base64
image. I am always getting the error.
FileSyst
hi I just changed my code as follows,
List<int> imageBytes = widget.fileData.readAsBytesSync();
print(imageBytes);
String base64Image = base64Encode(imageBytes);
and this is working fine now.
It is better to read it asynchronously as the image can be very large which may cause blocking of main thread
List<int> imageBytes = await widget.fileData.readAsBytes();
you can simply change the image to string :
final bytes = Io.File(imageBytes.path).readAsBytesSync();
String img64 = base64Encode(bytes);