Currently I am saving Appointment in Mssms (Microsoft sql server).Now I need the Primary key of that recently saved appointment and have to pass it to another screen i.e Services Where I have to select services of that Appointment. Any help will be appreciated. Here is code which I have tried:
BookAppoitment() async {
String date = '${datee.day}-${datee.month}-${datee.year}';
print(date);
String url = 'http://${ip}/workshopp/api/customer/bookoppointment';
var data = {
'mobile_no': phoneNo,
'reg_no': widget.regno.toString(),
'Date': date.toString(),
'Time': _value.toString(),
'Bay_no': (countBay + 1).toString(),
};
print(data.toString());
var response = await http.post(Uri.parse(url), body: data);
// using api post method in response getting appointment id in browser but in flutter causes error
if (response.statusCode == 200) {
Appointment_no = json.decode(response.body);
setState(() {
});
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("saved")));
} else {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(response.body)));
print(response.body);
}
}
//where passing that appointment id on proceed button
Navigator.push( context, MaterialPageRoute( builder: (context) => Services( app_id: Appointment_no, )));