Persistent "Function is empty or cannot be parsed" error - Blocking all Custom Functions

Widgets & Design

Hello FlutterFlow Community & Support Team,

I'm encountering a critical and persistent issue with custom functions in my project that is severely blocking development. I've tried extensive troubleshooting, but the problem persists.

The Problem:

When creating or saving any custom function (e.g., createDocumentReference, formatLatLng, as a function), I consistently receive the error message:

"The function is empty or cannot be parsed. Make sure not to modify code outside of the designated area."

This error occurs even with minimal, correct Dart code, and prevents the custom function from being saved or compiled.

(code below)

import 'package:cloud_firestore/cloud_firestore.dart';

DocumentReference createDocumentReference(

String collectionPath,

String documentId,

) {

return FirebaseFirestore.instance.collection(collectionPath).doc(documentId);

}


(This function is supposed to return a DocumentReference from a String ID, with Return Type DocumentReference, Document Type gates, and String arguments collectionPath and documentId).

What have you tried so far?

Troubleshooting Steps Already Taken (Extensive):

I've meticulously followed all standard troubleshooting steps and community suggestions:

  • Clean Code Pasting: For every attempt, I've completely deleted all existing code in the editor, and then pasted only the essential, clean Dart code (like the createDocumentReference example above).

  • Dependency Verification: Confirmed that cloud_firestore (and uuid for other functions) are correctly listed in Project Dependencies (cloud_firestore: ^5.0.0 etc.).

  • Function/Widget Settings: Ensured correct Function Name, Return Type, Document Type (gates), Nullability, and Arguments (String collectionPath, String documentId).

  • Error Checking: Repeatedly clicked "Check For Errors" and "Save Function/Action" after each attempt.

  • Environment Refreshes:

    • Performed multiple hard refreshes (Ctrl+Shift+R / Cmd+Shift+R) of the FlutterFlow browser tab.

    • Logged out and logged back in to FlutterFlow.

    • Tried creating/saving custom functions in an Incognito/Private browser window.

  • Function Re-creation: Deleted and recreated the custom function from scratch multiple times.

  • Code Copilot Failure: Even trying to use Code Copilot to generate the createDocumentReference function fails, giving a "Null check operator used on a null value" error, indicating a bug within the AI tool itself.

Did you check FlutterFlow's Documentation for this topic?
No
2
1 reply