fix delete single

This commit is contained in:
Nico
2025-06-19 17:00:37 +02:00
parent fccc0f8522
commit ce73ffcbcf

View File

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