convertImageFileToString function

Future<String> convertImageFileToString(
  1. XFile image
)

This function converts an image file into a base 64 encoded string. The image parameter is a cross-platfrom file. It is treated as a list of bytes. This is useful if you are using tools like crop to get a new image and then having to save the image as a string.

Implementation

Future<String> convertImageFileToString(XFile image) async {
  List<int> imageBytes = await image!.readAsBytes();
  return base64Encode(imageBytes);
}