I am new to flutter. I am trying to delete a particular document when the datefrom field matches with current time. How and where shall I call the delete function? Note: It must delete even when the app is not in use
This is my current code:
getText() {
if (dateTime == null) {
return 'Select Datetime';
} else {
return DateFormat('MM/dd/yyyy HH:mm').format(dateTime!);
}
deletetask() async {
if (time == getText()){
await FirebaseFirestore.instance
.collection('mytasks')
.doc('time')
.delete()
.then((value) => FirebaseStorage
.instance
.refFromURL('image')
.delete());
}