Custom Action Won't Compile - no errors given

Custom Code

I have this code I need so I can get a list of JSONs to use in an API call to create multiple rows at once.

I tried looking in Docs but don't see anything relevant (maybe I'm just not finding the right page).

UPDATE: have now tried changing all use of the custom Data Type to JSON instead, and the error is ultimately the same.

Info on the custom functions & data type used:

It calls two functions that FlutterFlow is happy with. But one returns a custom data type (because FlutterFlow would not allow me to return a List<List<String>> as I tried at first, so I just made a "listModel" DataType - which is a string value called "name", and a list<string> value called "list").

The first custom function: takes a string& returns a list of strings.

The second custom function: takes a list<string> and returns a list<ListModelStruct>. ( Just splits each string in the passed list into it's own list of strings). Update: It now returns a JSON with a list inside.

Here is the code:

List<Map<String, dynamic>> singleJsonToMultiJson(
  dynamic inJson,
  String inItemSep,
  String inPartSep,
  String style,
  {bool allowEmptyStrings = true}
) {
  // Extract the original values of "name" and "main" from inJSON
  String ogName = inJson['name'];
  String ogMain = inJson['main'];

  // use splitStringToItemList and pass in ogName/ogMain and inItemSep
  List<String> nameItems = splitStringToItemList(ogName, inItemSep);
  List<String> mainItems = splitStringToItemList(ogMain, inItemSep);

  // List to return later
  List<Map<String,dynamic>> jsonList = [];

  // CHECK Style
  if (style == 'strings') {
  // Return = list of JSONs with strings for Name & Main
    for (int i = 0; i < nameItems.length; i++) {
      // Create copy of inJson
      Map<String,dynamic> jsonCopy = Map.from(inJson);
      // Replace main/name in jsonCopy with items from nameItems & mainItems
      jsonCopy['name'] = nameItems[i];
      jsonCopy['main'] = mainItems[i];
      // Add jsonCopy to jsonList
      jsonList.add(jsonCopy);
    }
  }

  if (style == 'ListModelStruct') {
    // Return list of JSONs with list of strings for Name & Main
    // First - Convert "name" and "main" into ListModelStruct using splitListStringToListList and pass nameItems/mainItems and inPartSep
    List<ListModelStruct> nameList = splitListStringToListList(nameItems, inPartSep, allowEmptyStrings);
    List<ListModelStruct> mainList = splitListStringToListList(mainItems, inPartSep, allowEmptyStrings);
  
    // Return = list of JSONs with list of strings for Name & Main
    for (int i = 0; i < nameList.length; i++) {
      // Create copy of inJson
      Map<String,dynamic> jsonCopy = Map.from(inJson);
      // Replace main/name in jsonCopy with items from nameList/mainList
      jsonCopy['name'] = nameList[i].list;
      jsonCopy['main'] = mainList[i].list;
      // Add jsonCopy to jsonList
      jsonList.add(jsonCopy);
    }
  }
return jsonList;
}

Any ideas (fixes or work arounds)?

What have you tried so far?

1) I tried changing the return type around (with Future, without. etc.).

2) Made "inPartSep" non-nullable in code despite selecting it as nullable because it was coming up as an error (now no error is returned).

3) Removing the preset value to the bool, etc.

4) put it in VS Code to see if it highlighted any errors (have dart/flutter packages).

UPDATE: Have tried using JSON instead of custom Data Types - no change in end result.

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