I created two custom structs : "Question" and "Reponse".
"Question" is defined like that :
{
List<ReponseStruct> values,
String? title
}
And at some time I need to add a row to the values list of a QuestionStruct object.
So I wrote a custom function to do this :
QuestionStruct addAnswerRow(QuestionStruct currentQuestion) {
QuestionStruct copy = QuestionStruct.fromSerializableMap( currentQuestion.toSerializableMap() );
List<ReponseStruct> temp = List<ReponseStruct>.from( copy.values );
temp.add(new ReponseStruct());
copy.values = temp;
return copy;
}
I tried this function using Android Studio directly, and there is no error when compiling it / using it.
So I tried to write this on FlutterFlow :
And I have this error :
The method 'fromSerializableMap' isn't defined for the type 'QuestionStruct'. Try correcting the name to the name of an existing method, or defining a method named 'fromSerializableMap'.
Does anybody know why I have this error ?
I checked the source code, and the function is actually here :
For those looking for a solution, just replace :
QuestionStruct copy = QuestionStruct.fromSerializableMap( currentQuestion.toSerializableMap() );
By :
QuestionStruct copy = QuestionStruct.fromMap( currentQuestion.toMap() );