Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@becek2n
Last active May 9, 2020 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save becek2n/0a608f84c92adb5566dd7c9921856b25 to your computer and use it in GitHub Desktop.
Save becek2n/0a608f84c92adb5566dd7c9921856b25 to your computer and use it in GitHub Desktop.
//fungsi save
void _deleteKaryawan(KaryawanModel model){
final db = new DbLite();
PopupHelper().alertDialogCuprtino(context, "Mohon tunggu...");
Future.delayed( Duration(seconds: 3), (){
db.deleteKaryawan(model.id).then((value){ //hapus data yg ada di database
if(value > 0){
setState(() {
modelList.remove(model); //hapus data yg ada di list
});
Navigator.of(context, rootNavigator: true).pop();
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return new WillPopScope(
onWillPop: () async => false,
child: new CupertinoAlertDialog(
title: new Text("Yeay, data berhasil dihapus", style: TextStyle(fontSize: 12), ),
actions: <Widget>[
new FlatButton(
onPressed: (){
Navigator.of(context, rootNavigator: true).pop();
},
child: new Text("Ok"),
)
],
),
);
}
);
}else{
Navigator.of(context, rootNavigator: true).pop();
PopupHelper().alertDialogCuprtinoMsg(context, "Oops, terjadi kesalahan!");
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment