Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete document automatically when it matches the time inside firebase for flutter? [duplicate]

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 enter image description here

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());
      }
like image 476
Sriram Avatar asked Oct 15 '25 06:10

Sriram


1 Answers

I believe what you're looking for are scheduled functions and they are documented here.

like image 147
Vandad Nahavandipoor Avatar answered Oct 17 '25 22:10

Vandad Nahavandipoor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!