Skip to content

Instantly share code, notes, and snippets.

@soeleman
Created July 23, 2021 17:12
Show Gist options
  • Save soeleman/3d57497e3eafbed57db4217584fc5556 to your computer and use it in GitHub Desktop.
Save soeleman/3d57497e3eafbed57db4217584fc5556 to your computer and use it in GitHub Desktop.
ImagePicker then Send via Post
File _image;
Future cameraImage() async {
var image = await ImagePicker.pickImage(
source: ImageSource.camera,
maxHeight: 240.0,
maxWidth: 240.0,
);
setState(() {
_image = image;
});
}
submitForm() async {
final response = await http.post(
uri,
headers: {
AuthUtils.AUTH_HEADER: _authToken
},
body: {
'user_id': userId
'photo': _image != null ? 'data:image/png;base64,' +
base64Encode(_image.readAsBytesSync()) : '',
},
);
final responseJson = json.decode(response.body);
print(responseJson);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment