You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.
Current Behavior
FlutterFlow does not correctly handle the mapping of JSON objects to data types (structs) when the data type has numeric (integer or double) fields and the JSON includes null values as empty strings. The implementation of castToType() in ./lib/flutter_flow/flutter_flow_util.dart doesn't anticipate an empty string in the case of a double or integer resulting in an exception when it tries to return the empty string as one of the numeric types.
Expected Behavior
Change castToType() to check for empty strings in the case of integers and doubles and return a null value.
Steps to Reproduce
Create a new project.
Create a data type with numeric fields.
Create an API call which returns a JSON string containing null values for the numeric fields.
Create a new page.
Add a button.
Add an action to the button to trigger the API and map the resulting JSON to the data type.
The mapping will never succeed because an exception will be raised in castToType().
Reproducible from Blank
The steps to reproduce above start from a blank project.
- FlutterFlow version: 5.2.2 (released February 19, 2025)
- Platform: macOS
- Browser name and version:
- Operating system and version affected:
Additional Information
Added the following code to both the int and double cases in the implementation of castToType() in lib/flutter_flow/flutter_flow_util.dart and all my problems went away.
// Handle null values (empty strings)
if ((value is String) && (value == '')) return null;
The text was updated successfully, but these errors were encountered:
In this case, the issue is related to the data type configuration. You have the field set as Int in FlutterFlow, while the JSON response is returning a String. It’s not returning null; instead, it's returning an empty string (''). This isn't a FlutterFlow issue—it's a mismatch between the data type and the response.
I recommend either:
Modifying the API response to return the value as an integer.
OR
Adjusting the DataType in FlutterFlow to String. After parsing, you can handle any empty string validations directly within FlutterFlow as needed.
This should help resolve the issue. Let me know if you need further assistance!
Can we access your project?
Current Behavior
FlutterFlow does not correctly handle the mapping of JSON objects to data types (structs) when the data type has numeric (integer or double) fields and the JSON includes null values as empty strings. The implementation of castToType() in ./lib/flutter_flow/flutter_flow_util.dart doesn't anticipate an empty string in the case of a double or integer resulting in an exception when it tries to return the empty string as one of the numeric types.
Expected Behavior
Change castToType() to check for empty strings in the case of integers and doubles and return a null value.
Steps to Reproduce
The mapping will never succeed because an exception will be raised in castToType().
Reproducible from Blank
Bug Report Code (Required)
IT48k8jq349Psbxc1pPpbfowpDwsQ3k7UL8ZkOpuZxI8J5zKB+wAYvf7P1FWTL3mdwhUf0yWimM0xvfqktntMu4EORSWQLpSzqtiVQnJUlK5bIyLPqiRfW1fN8FPCUCB4baFoSRAOtdpSEIF3U2MGvO+dCjUNqb2NmosROSbLdeK2SrDX1iXc2URm05KZDPz
Visual documentation
Environment
Additional Information
Added the following code to both the int and double cases in the implementation of castToType() in lib/flutter_flow/flutter_flow_util.dart and all my problems went away.
The text was updated successfully, but these errors were encountered: