Commit 0d71183e authored by Fikri's avatar Fikri

consume api delete

parent c3e4117c
......@@ -31,8 +31,9 @@ Future<bool> savecontact(nama, email, nohp, message) async {
}
Future<bool> deleteContact(id) async {
final response = await http.delete(
Uri.parse('$cmd/contact/delete/$id'),
final response = await http.post(
Uri.parse('$cmd/contact/delete'),
body: jsonEncode({"idContact": id}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
......
......@@ -613,7 +613,56 @@ class _Dashboard4State extends State<Dashboard4> {
viewUser(context);
} else if (value == 2) {
print("you choose Delete...");
deleteContact(context);
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text("Warning"),
content: Text(
"Are you sure want to delete data page ${pgm['idContact']}?"),
actions: <Widget>[
TextButton(
child: const Text("Yes"),
onPressed: () {
Navigator.pop(context);
deleteContact(
pgm['idContact'])
.then(
(isSuccess) {
if (isSuccess) {
setState(() {});
Scaffold.of(
this.context)
.showSnackBar(
const SnackBar(
content: Text(
"Delete data success"),
),
);
} else {
Scaffold.of(
this.context)
.showSnackBar(
const SnackBar(
content: Text(
"Delete data failed"),
),
);
}
},
);
},
),
TextButton(
child: const Text("No"),
onPressed: () {
Navigator.pop(context);
},
),
],
);
},
);
}
},
))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment