API calls + environment variables = failed builds

Database & APIs
Resolved

I need help with setting properly environment variables with API.

I have added API Calls to my backend. When i run test calls using FF Response & Test they work fine.

However when i build, build fails with following error:

(...)
Running pod install...                                           1,623ms
Running Xcode build...                                          
Xcode build done.                                           21.7s
Failed to build iOS app
Error (Xcode): lib/backend/api_requests/api_calls.dart:52:5: Error: Local variable 'baseUrl' can't be referenced before it is declared.

Could not build the application for the simulator.
Error launching application on iPhone 16 Pro.

I have downloaded code to see where exactly is the problem:

How i have my API and variables set up:

  • API

    • API Base URL set as [base_url] parameter (it will be different for different environments)

    • set up group variable base_url

  • Environment: development

    • defined apiURL variable with my localhost endpoint

  • In all actions using API calls i am providing value for base_url indicating environment apiURL variable

What have you tried so far?
  • i have setup actions that use API Calls without providing base_url value (hoping it will fallback to default API group variable)

  • i have setup in group variable default value for base_api

    • used hardcoded url to my API

    • pointed to environment variable

For all those cases, the result was the same.

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