I cannot send my base64 String with the Post Function, and the only error I get is: "Bad state: Cannot set the body fields of a Request with content-type 'multipart/form-data'." when I remove the header, I get this error: "XMLHttpRequest error." Does anyone know how I can do that? I also tried base64 code from an Online Converter to be sure my String is ok.
TextButton(
onPressed: () async {
final base64 = await documentToBase64(document);
final urlEncBase64 = Uri.encodeComponent(base64);
final uri = Uri.parse(myurl);
await http.post(uri,
headers: {
'content-type': 'multipart/form-data'
},
body: {
'b64': '$urlEncBase64',
}).then((res) {
print(res.statusCode);
}).catchError((err) {
print(err);
}
);
},
child: const Text('Send'),
),