Last active
May 9, 2020 16:10
-
-
Save becek2n/0a608f84c92adb5566dd7c9921856b25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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