Unexpected null value | Is backend query for null/empty/new Document possible?

Troubleshooting

Hello! 😊 I have a properties database that stores data about individual real estate properties. I have a property page that I'm using to:

  1. view a real estate property's details;

  2. edit a real estate property's details;

  3. create a new real estate property.

For #1 and #2, I have no problems; I perform a Document from Reference query that retrieves data about a property via a Doc Reference propertyID page parameter. I also have a pageMode parameter of type Enum with 3 options: "view", "edit" and "create" for conditional visibility purposes.

For #3, I keep running into various "Unexpected null value" errors whenever I create a "Create new property" link (pageMode = create) from another page that either

(a) doesn't pass a propertyID parameter, or;
(b) passes a "Null" value for the propertyID parameter.

Note: the Debug Panel, when running the page with pageMode = create, shows that a widget propertyFeatureName has Null value, however all of those component widgets clearly have manually inputted strings as value (i.e. aren't tied to a Document):

Questions:

  • Is what I'm trying to achieve (i.e. 1 page to view/edit/create a Document) possible?

  • When there is a conditional visibility not achieved, does the code still "run under the hood" for that widget? For example, if I have a Text widget with a variable String (pulled from the page-level query), could that cause an error if the variable isn't found due to the backend query looking up a null or non-existent Document?

  • Why does it say that propertyFeatureName is Null when I pass a null or empty propertyID parameter?

Thank you very much for your help!

What have you tried so far?
  • Verified that all variables in the page have default values.

  • Created if/then scenarios to only perform the page backend query if pageMode != create.

  • Created conditional visibility for all widgets such that they don't show if pageMode != create.

  • Created if/then scenarios for widget variables that would pull from the backend query.

  • Tried creating a "default Property document" to use instead for the backend query whenever I (a) doesn't pass a propertyID parameter, or; (b) passes a "Null" value for the propertyID parameter.

Did you check FlutterFlow's Documentation for this topic?
Yes
5