Support for dynamic keys in maps

Database & APIs

Does Flutterflow support dynamic keys in maps?

It looks like when using the 'Data Schema' builder inside FF, that it does not. Because when setting up your data model in the 'Data Schema' via Flutterflow, each field name must be defined by a statically typed in name. You can't input a variable or another data type for the field name.

I need to create maps with dynamic keys, where the key is a date. (Another use case is where key is a different user uid.)

Example here, where the "blocked_dates" data type would be a map, and the key is each date (year-month-day)

{
  "owner_uid": "U12345",
  "blocked_dates": {
    "2025-01-16": {
      "blocked_times": [
        {
          "start_time": "07:00",
          "end_time": "12:00"
        }
      ]
    },
    "2025-01-15": {}, 
    "2025-02-01": {
      "blocked_times": [
        {
          "start_time": "09:00",
          "end_time": "17:00"
        }
      ]
    }
  }
}

If you don't support maps with dynamic keys, it requires (in my scenario) more than 2x the number of collections, which doubles the cost of Firestore queries. It also requires a lot of on-device processing, to query multiple collections, and filter and loop on the results. Instead of a simple, direct query to a single document with a dynamic key map.

Please let me know if I'm missing something on this!

What have you tried so far?

2 weeks of playing around in Data Schema, Claude, ChatGpt, googling this forum/stackoverflow/reddit to find a way to get FF to support dynamic keys

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