Future userPasswordUpdate() async {
String passwordU = password.text;
String confirmPasswordU = confirmPassword.text;
String oldPasswordU = oldPassword.text
For the image upload you can also use the Dio
library to post image on server with requested parameters.Please check the below example of it.
Dio dio = new Dio(); // with default Options
// Set default configs
dio.options.baseUrl = BASE_URL;
dio.options.connectTimeout = 5000; //5s
dio.options.receiveTimeout = 3000;
dio.options.headers[HEADER_AUTH_TOKEN_KEY] = HEADER_AUTH_TOKEN_VALUE;
dio.options.headers[HEADER_VERSION_KEY] = HEADER_VERSION_VALUE;
FormData formData = new FormData.fromMap({
"password": passwordU,
"confirmPass": confirmPasswordU,
"oldpassword": oldPasswordU,
"YOUR_IMAGE_PARAMETER_NAME": await MultipartFile.fromFile(imageFile.path,filename: imageFile.path.split("/").last),
});
var response = await dio.post(REGISTRATION_URL, data: formData);
if (response.statusCode == 200) {
apiResponse.onSuccess(response.toString(), eventType);
print("Image Uploaded");
} else {
apiResponse.onError('Failed to load post');
print("Upload Failed");
}
}
Inside the pubspec.yaml used this library,
dio: ^3.0.9
For the info about the library , you need to check this link Click