4

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());
      }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sriram
  • 433
  • 4
  • 20

1 Answers1

2

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

  • it's only available on Blaze pricing plan though... Not so sure about switching to uncapped billing while I'm still learning – Sriram Mar 08 '22 at 07:13
  • Yes that's unfortunately the case; this is a paid-for functionality. You mentioned that you want this functionality to kick-in even when your app is not running; hence you either have to write a custom backend that integrates with your Firebase project or you have to pay for Firebase Blaze plan and have scheduled functions. – Vandad Nahavandipoor Mar 08 '22 at 07:14
  • Keep in mind that there's a quite generous free tier for Cloud Functions on the paid plan. So while you will need to have a billing account for the project, you won't have to pay for your Cloud Functions usage until you exceed that free quota. – Frank van Puffelen Mar 10 '22 at 22:21