fieldsToJson method
Method to help in the task of passing the provided List<FormField>
to its Map<String, dynamic>
representation,
that is useful when it comes to pass the Form
data through, for instance, a request body
Implementation
Map<String, dynamic> fieldsToJson(List<FormField> fields) {
final data = <String, dynamic>{};
int index = 0;
while (index < fields.length) {
fields[index].field.map(
nothing: (_) => {},
just: (val) {
data[fields[index].name] = val.value;
},
);
index++;
}
return data;
}