1

I built a multi-tab Flutter Web registration form (Clients and Workers) that submits data to Firebase Firestore using the .add() method.

It was working fine for a few days, but now I'm getting this error in the console:

FirebaseError: FirebaseError: [code=invalid-argument]: Request is missing required field: write.operations

Here’s how I’m submitting data:

await FirebaseFirestore.instance.collection("registrations").add({
  "fullName": fullNameController.text.trim(),
  "email": emailController.text.trim(),
  // more fields...
});

What I Tried:

  • I used FirebaseFirestore.instance.collection("registrations").add({...}) to submit the form data.

  • Verified that all required fields have valid values before calling .add().

  • Ensured Firebase security rules are not blocking the request (allow read, write: if true;).

  • Simplified the data to just one key-value pair to check if it was due to large data — still failed.

  • Tested in Flutter Web (Chrome) — fails with the 400 invalid-argument error.

  • Tested the same code in Flutter Android emulator — works fine without error.

  • Also rechecked if any of the text controllers were null or empty.

What I Expected:

  • The .add() call should successfully create a new document in the registrations Firestore collection.

  • The Firestore backend should return the new document ID as usual.

  • No errors should appear in the browser console or terminal.

2
  • I suspect there may be something wrong with the values you're passing. Try it with hard-coded values, and if that works, print the values you're passing to Firestore to check them for empty/null/anything else unusual. Commented Jul 23 at 14:50
  • Please also edit your question and add the information Frank asked for. Commented Jul 24 at 7:57

1 Answer 1

0

If you are using cloud_firestore try the code below

await FirebaseFirestore.instance.collection("registrations").doc().set({
  "fullName": fullNameController.text.trim(),
  "email": emailController.text.trim(),
  // more fields...
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.