I'm trying to create a register page in flutter. Using HTTP package to post data to back end and in turn i'm receiving status message. I need to access the session_id(and csrf value) stored in cache of the API, so that i can set its value in shared preference for further session management. my code to post data is:
Future registeruser(String firstname, String lastname,String email,String password,int
phone) async {
String apiUrl="api here";
final body ={"firstname":firstname,
"lastname":lastname,
"email":email,
"password":password,
"phone":phone,
};
final response= await http.post(apiUrl,headers:{'Content-type':
'Application/json','Accept':'Application/json'} ,body:body );
var convertedDatatoJson= jsonDecode(response.body);
return convertedDatatoJson;
}
var res =await registeruser(firstname, lastname, email, password, phone);
if(res.containsKey('status')){
setState(() {
message=res['status'];
});
if(res['status']==1){
Navigator.pop(context);
}
else{
print('error');
}
}
}},
but how do i get the data from cache of the API and store in shared preferences, i'm quite new to flutter please help me.