diff --git a/lib/screens/viewEntries/view_cams.dart b/lib/screens/viewEntries/view_cams.dart index d830252..6c8c6c0 100644 --- a/lib/screens/viewEntries/view_cams.dart +++ b/lib/screens/viewEntries/view_cams.dart @@ -34,7 +34,7 @@ class _ViewEntriesState extends State { // loads the entries @override void initState() { - reloadAllEntries(); + reloadAllEntries().then((val) => setState(() {})); super.initState(); } @@ -158,14 +158,13 @@ class _ViewEntriesState extends State { motion: const ScrollMotion(), children: [ SlidableAction( - onPressed: (context) { - DeleteMainEntries.deleteSingle( + onPressed: (context) async { + await DeleteMainEntries.deleteSingle( widget.dbType, mainEntries[index]['ID'.toString()], ); - setState(() { - reloadAllEntries(); - }); + reloadAllEntries() + .then((val) => setState(() {})); }, backgroundColor: Colors.red, foregroundColor: Colors.white, @@ -176,14 +175,14 @@ class _ViewEntriesState extends State { ], ), child: ListTile( - title: Text( - '${index + 1}'), + title: Text('${index + 1}'), subtitle: Text( dateFormat.format(DateTime.parse( mainEntries[index]["Datum"])), ), trailing: Checkbox( - value: mainEntries[index]['Sent'] == "0" || mainEntries[index]["Sent"] == "" + value: mainEntries[index]['Sent'] == "0" || + mainEntries[index]["Sent"] == "" ? false : true, onChanged: null, @@ -253,14 +252,13 @@ class _ViewEntriesState extends State { motion: const ScrollMotion(), children: [ SlidableAction( - onPressed: (context) { - DeleteTemplates.deleteSingle( + onPressed: (context) async { + await DeleteTemplates.deleteSingle( widget.dbType, templates[index]['ID'].toString(), ); - setState(() { - reloadAllEntries(); - }); + reloadAllEntries() + .then((val) => setState(() {})); }, backgroundColor: Colors.red, foregroundColor: Colors.white, @@ -298,8 +296,7 @@ class _ViewEntriesState extends State { }); } }, - title: Text( - '${index + 1}'), + title: Text('${index + 1}'), subtitle: Text( dateFormat.format( DateTime.parse(templates[index]["Datum"])),