Converting Image to base64 and base64 String to Image

#Selecting image from galley

final ImagePicker _picker = ImagePicker();


final XFile? image = await _picker.pickImage(
    source: ImageSource.gallery, imageQuality: 100);

#Converting image

List<int> imageBytes = File(image.path).readAsBytesSync();
String imageB64 = base64Encode(imageBytes);//will get base64 encoded string
Uint8List bytes = base64Decode(imageB64);//decoded code

#To load decoded base64 to image we use Image.memory

Image.memory(bytes!, height: 100.0, width: double.infinity,)


Sign In or Register to comment.