Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void takePhoto() async {
- final pickedImage =
- await ImagePicker().pickImage(source: ImageSource.camera);
- if (pickedImage != null) {
- profileImagePath = pickedImage.path;
- }
- }
- static Future<dynamic> uploadPhoto(String imagePath) async {
- try {
- FormData formData = FormData.fromMap({
- "profile": await MultipartFile.fromFile(imagePath, filename: "profile.jpg")
- });
- Response response = await Dio().post(
- "<url>",
- data: formData,
- options: Options(
- headers: <String, String>{
- 'Authorization': 'Bearer <some token>',
- },
- ),
- );
- return response;
- } on DioError catch (e) {
- log(e.response?.data);
- log(e.response?.statusCode);
- return e.response;
- } catch (_) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement