upload profile

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

@ -102,6 +102,7 @@ class AppSettings {
static String acceptBookingRequestsUrl = host + 'ordernow'; static String acceptBookingRequestsUrl = host + 'ordernow';
static String acceptRequestUrl = host +"friend-request/accept"; static String acceptRequestUrl = host +"friend-request/accept";
static String rejectRequestUrl = host +"friend-request/reject"; 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 { static Future<bool> addTankers(payload) async {
var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId), var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId),

Loading…
Cancel
Save