upload profile

dev
Sneha 2 years ago
parent 5e7a14fd3e
commit 6a3d1ce26b

@ -41,14 +41,14 @@ class _DashboardState extends State<Dashboard> {
/*Future<void> uploadProfileApi(image) async {
Future<void> uploadProfileApi(image) async {
var payload = new Map<String, dynamic>();
payload["picture"] = image.toString();
var response1= await AppSettings.updateProfilePicture(payload);
print(response1);
}*/
}
@override
void initState() {
@ -100,7 +100,7 @@ class _DashboardState extends State<Dashboard> {
setState(() {
AppSettings.updatedImage = imageTemp;
});
// uploadProfileApi(AppSettings.updatedImage);
uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path);
@ -118,7 +118,7 @@ class _DashboardState extends State<Dashboard> {
AppSettings.updatedImage = imageTemp;
});
//uploadProfileApi(AppSettings.updatedImage);
uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) {

@ -102,6 +102,7 @@ class AppSettings {
static String acceptBookingRequestsUrl = host + 'ordernow';
static String acceptRequestUrl = host +"friend-request/accept";
static String rejectRequestUrl = host +"friend-request/reject";
static String profilePicUrl = host + 'supplier/profile-picture';
@ -337,6 +338,25 @@ class AppSettings {
}
}
static Future<bool> updateProfilePicture(payload) async {
var uri = Uri.parse(profilePicUrl + '/' + supplierId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
try {
var _response = json.decode(response.body);
print(_response);
return true;
} catch (e) {
// display error toast
return false;
}
} else {
return false;
}
}
static Future<bool> addTankers(payload) async {
var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId),

Loading…
Cancel
Save