flutter图片转base64

接口要求图片转base64

void getImageByGallery(index)async{

ImagePicker.pickImage(source: ImageSource.gallery).then((value)async{

List bytes =await value.readAsBytes();

String bs64 = base64Encode(bytes);

String bs64Image ="data:image/png;base64,"+bs64;

print(bs64Image);

});

}

你可能感兴趣的:(flutter图片转base64)