Skip to main content
RapidDev - Software Development Agency
flutterflow-tutorials

How to Delete Data from Your FlutterFlow Database

Delete a single Firestore document in FlutterFlow by adding a Backend Call action set to Delete Document and passing the document reference. For subcollections, you must delete all child documents before the parent using a Custom Action — Firestore does not cascade deletions. For batch deletes or deleting entire collections, use a Cloud Function. Always show a confirmation dialog before any destructive delete action.

What you'll learn

  • How to delete a single Firestore document using FlutterFlow's Delete Document action
  • How to delete subcollection documents before deleting a parent document
  • How to perform batch deletes and collection-level deletes via Custom Actions and Cloud Functions
  • How to implement a confirmation dialog to prevent accidental data deletion
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate10 min read30-45 minFlutterFlow Free+ (Firestore or Supabase)March 2026RapidDev Engineering Team
TL;DR

Delete a single Firestore document in FlutterFlow by adding a Backend Call action set to Delete Document and passing the document reference. For subcollections, you must delete all child documents before the parent using a Custom Action — Firestore does not cascade deletions. For batch deletes or deleting entire collections, use a Cloud Function. Always show a confirmation dialog before any destructive delete action.

Complete guide to deleting Firestore and Supabase data in FlutterFlow

Deleting data in FlutterFlow ranges from simple (single document delete via a built-in action) to complex (recursive subcollection cleanup requiring custom code). The right approach depends on your data structure. Flat collections with no subcollections use the built-in Delete Document action. Documents with subcollections require a Custom Action to delete children first. Large-scale or scheduled deletes use Cloud Functions. This tutorial covers all four scenarios, including the confirmation dialog pattern that prevents users from accidentally deleting data they cannot recover.

Prerequisites

  • A FlutterFlow project connected to Firestore or Supabase with at least one collection containing test data
  • A page with a list of documents that users should be able to delete
  • Basic understanding of FlutterFlow Action Flows and Backend Queries
  • Firestore Security Rules that allow delete operations for authenticated users on the relevant collection

Step-by-step guide

1

Delete a single document with a confirmation dialog

Select the Delete button widget on your list item. Open the Action Flow editor. As the first action, add a Show Alert Dialog action: set the title to 'Delete Item', the message to 'This cannot be undone. Are you sure?', the confirm button text to 'Delete' with a red color, and the cancel button text to 'Cancel'. Only continue the flow if the user confirms. After the dialog confirmation action, add a Backend Call action → set the Call Type to Delete Document. In the Document Reference field, bind to the document reference from your Backend Query (for list items, this is typically the document reference of the current loop item — accessible via the Generate Dynamic Children binding menu). After the delete action, add a Show Snackbar action with text 'Deleted successfully'. The list will automatically update because the Backend Query re-runs.

Expected result: Tapping Delete shows a confirmation dialog. Confirming removes the document from Firestore and the list updates automatically.

2

Delete a document with subcollections (Custom Action)

If your Firestore document has subcollections (e.g., a posts document with a comments subcollection), you cannot use the built-in Delete Document action directly — orphaned subcollection documents remain even after the parent is gone, still consuming storage and reads. Create a Custom Action named deleteDocWithSubcollections. Import firebase_cloud_firestore. Write: final docRef = FirebaseFirestore.instance.doc(docPath); final commentsSnap = await docRef.collection('comments').get(); for (final comment in commentsSnap.docs) { await comment.reference.delete(); } await docRef.delete();. Pass the document path as a String parameter. Call this Custom Action from the Action Flow instead of the built-in Delete Document action. This ensures all comments are deleted before the parent post.

Expected result: The document and all its subcollection documents are deleted, with no orphaned data remaining in Firestore.

3

Batch delete multiple documents

For deleting all items matching a condition (e.g., delete all notifications older than 30 days, or delete all selected items in a multi-select list), create a Custom Action named batchDelete. Import firebase_cloud_firestore. Use WriteBatch for up to 500 documents: final batch = FirebaseFirestore.instance.batch(); for (final docRef in docRefs) { batch.delete(docRef); } await batch.commit();. Pass a List<DocumentReference> as the parameter. In FlutterFlow, use a multi-select list (checkboxes bound to App State selectedIds) and on the Delete Selected button, call batchDelete passing the selected document references. WriteBatch is atomic — all deletions succeed or all fail together — which prevents partial deletes that leave the UI in an inconsistent state.

Expected result: All selected documents are deleted in a single atomic Firestore operation, and the list updates to show only the remaining items.

4

Delete a Supabase row

For Supabase-backed FlutterFlow projects, deleting a row uses the Backend Call action configured differently. In the Action Flow, add Backend Call → Supabase row delete. Select the table, then set the matching condition — typically the id column equals the row ID from your current list item. The Supabase delete follows the same confirmation dialog pattern as Firestore (add the Show Alert Dialog action first). Ensure your Supabase Row Level Security (RLS) policy allows delete for the authenticated user — a common mistake is enabling RLS without adding a delete policy, which silently blocks the operation without a clear error. Test in the Supabase SQL editor: DELETE FROM table WHERE id = 'test-id' while authenticated as a test user to verify the RLS policy works.

Expected result: The Supabase row is deleted and the list refreshes to remove the item.

5

Add an undo option after delete

A Snackbar with an Undo button dramatically reduces support requests from users who accidentally delete data. Instead of deleting immediately, implement a soft delete: add an isDeleted Boolean field to your Firestore documents (default false). On the 'Delete' action, update isDeleted to true and hide the item from the list by filtering the Backend Query (where isDeleted == false). Show a Snackbar with an Undo button — if tapped within 5 seconds, call Update Document to set isDeleted back to false. After the Snackbar dismisses, call a Cloud Function or scheduled task to permanently delete documents where isDeleted == true and deletedAt timestamp is older than 24 hours. This pattern is used by Gmail, Slack, and most productivity apps because it drastically reduces complaints about accidental deletions.

Expected result: Deleted items disappear from the list immediately, but a Snackbar with an Undo button allows recovery within 5 seconds before permanent deletion.

Complete working example

delete_doc_with_subcollections.dart
1// Custom Action: deleteDocWithSubcollections
2// Deletes a Firestore document and all its subcollection documents
3// Parameters: docPath (String) - the full Firestore path, e.g. 'posts/postId'
4// subcollections (List<String>) - e.g. ['comments', 'likes']
5import 'package:cloud_firestore/cloud_firestore.dart';
6
7Future<bool> deleteDocWithSubcollections(
8 String docPath,
9 List<String> subcollections,
10) async {
11 try {
12 final docRef = FirebaseFirestore.instance.doc(docPath);
13
14 // Delete all documents in each subcollection
15 for (final subcollection in subcollections) {
16 final subcollSnap =
17 await docRef.collection(subcollection).get();
18
19 // Use WriteBatch for efficiency (max 500 per batch)
20 final batches = <WriteBatch>[];
21 var batch = FirebaseFirestore.instance.batch();
22 var count = 0;
23
24 for (final doc in subcollSnap.docs) {
25 batch.delete(doc.reference);
26 count++;
27 if (count == 500) {
28 batches.add(batch);
29 batch = FirebaseFirestore.instance.batch();
30 count = 0;
31 }
32 }
33 if (count > 0) batches.add(batch);
34
35 for (final b in batches) {
36 await b.commit();
37 }
38 }
39
40 // Delete the parent document
41 await docRef.delete();
42 return true;
43 } catch (e) {
44 return false;
45 }
46}

Common mistakes when deleting Data from Your FlutterFlow Database

Why it's a problem: Deleting a parent document without first deleting its subcollections

How to avoid: Before deleting any document that has subcollections, delete all subcollection documents first using a Custom Action with a loop. For complex nested structures, use a Cloud Function with admin.firestore().recursiveDelete(docRef) which handles unlimited nesting automatically.

Why it's a problem: Performing delete actions without a confirmation dialog

How to avoid: Always add a Show Alert Dialog action as the FIRST step in any Action Flow that deletes data. Only proceed with the delete if the user confirms. Use red color for the confirm button and clear language about the irreversibility.

Why it's a problem: Assuming the UI list updates automatically after delete on a non-real-time Backend Query

How to avoid: Either enable real-time mode on the Backend Query (so Firestore change events automatically update the list), or after the delete action, add a Refresh Backend Query action to the Action Flow to force a re-fetch.

Best practices

  • Always back up your database before performing large-scale deletes — Firestore has no recycle bin, and deleted data cannot be recovered without a backup
  • Implement soft deletes (isDeleted flag) for user-facing data where accidental deletion is likely — hard delete only in scheduled cleanup jobs
  • Log all delete operations to a separate Firestore audit_log collection with who deleted what and when — required for GDPR compliance and useful for debugging data loss reports
  • Use Firestore Security Rules to restrict who can delete which documents — never rely on the UI to prevent unauthorized deletes
  • Test delete operations with your actual Firestore Security Rules in place — rules that work for read/write operations sometimes block delete operations unexpectedly
  • For compliance-regulated data (medical records, financial transactions), consider a legal hold policy that prevents deletion even by admins during investigation periods
  • Show an optimistic UI update (remove item from list immediately) and revert if the delete fails — this feels faster than waiting for Firestore to confirm before updating the list

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I am building a FlutterFlow app with Firestore. I need to delete a 'posts' document that has a 'comments' subcollection. Write a Dart Custom Action that takes a document path string, first deletes all documents in the 'comments' subcollection using WriteBatch for efficiency, then deletes the parent document. Handle the case where there are more than 500 comments by splitting into multiple batch commits.

FlutterFlow Prompt

Add a delete button to my FlutterFlow post list. When tapped, show a confirmation dialog with a red Delete button. If confirmed, call my deleteDocWithSubcollections custom action passing the current post document path. After deletion, show a success Snackbar and refresh the Backend Query on the posts list page.

Frequently asked questions

How do I delete all documents in a Firestore collection from FlutterFlow?

Deleting an entire collection cannot be done from the FlutterFlow visual editor — it requires iterating over all documents and deleting each one. Use a Cloud Function: const batch = db.batch(); const snapshot = await db.collection('collectionName').get(); snapshot.docs.forEach(doc => batch.delete(doc.ref)); await batch.commit(); — split into batches of 500 for large collections. Trigger this Cloud Function from a FlutterFlow API Call or directly from Firebase Console for admin-level operations.

Why does my Firestore delete action silently fail without an error?

The most common reason is Firestore Security Rules. If your rules do not include an explicit allow delete condition for the authenticated user, delete operations are silently blocked — there is no error thrown to the FlutterFlow app. Check Firebase Console → Firestore → Rules and ensure you have allow delete: if request.auth != null && request.auth.uid == resource.data.userId (or your equivalent permission check). Use the Firebase Rules Playground to test delete operations.

Can I undo a Firestore document delete?

Once a Firestore document is permanently deleted, it cannot be undone unless you have a backup. This is why implementing soft delete (isDeleted flag) before the permanent delete is the recommended approach for user-facing data. If you have Firebase's Point-in-Time Recovery enabled (Blaze plan, up to 7 days), you can restore data by contacting Firebase support or using the PITR restore command.

How do I delete a Firestore document field (not the entire document)?

To delete a specific field from a document (not the entire document), use an Update Document action in the Action Flow. In the field value, instead of a new value, use the FieldValue.delete() option. This removes just that field from the document while leaving all other fields intact. In FlutterFlow's Update Document action, look for the delete field option in the field value selector.

How do I delete data from Supabase with FlutterFlow?

Use the Backend Call action in Action Flow, set to Supabase row delete. Select the table and add a filter condition matching the row ID. Ensure your Supabase Row Level Security policy includes a DELETE policy for the authenticated user: CREATE POLICY delete_own_records ON table_name FOR DELETE USING (auth.uid() = user_id). Without this RLS policy, the delete will fail silently even if the UI appears to work.

What if I accidentally deleted important data in my FlutterFlow app?

If you have Firebase Point-in-Time Recovery enabled (Blaze plan), you can restore to a point before the deletion. If you have manual exports (Firebase Console → Firestore → Import/Export), restore from the latest backup. If neither is in place, data recovery may not be possible — this is why backups and soft delete patterns are strongly recommended before any delete functionality goes live. RapidDev can help set up automated Firestore backups to prevent future data loss.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.