Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Future<void> _takePicture(source) async {
- final prefs = await SharedPreferences.getInstance();
- final picker = ImagePicker();
- final imageFile = await picker.getImage(source: source);
- if (imageFile == null) {
- return;
- }
- var request = http.MultipartRequest(
- 'POST', Uri.parse('https://XXXX.xXXX/api/vehicle/addPhoto'));
- request.headers['Authorization'] =
- 'Bearer ' + prefs.getString('access_token');
- request.files
- .add(await http.MultipartFile.fromPath('file', imageFile.path));
- setState(() {
- this._saving = true;
- });
- var res = request.send();
- res.then((response) {
- print("dentro then");
- print(response.stream.toString());
- });
- print("reasonPhrase");
- print(res.toString());
- print("status code");
- setState(() {
- this._saving = false;
- });
- return;
- }
Add Comment
Please, Sign In to add comment