define function
Helper to set both a value and options for a form field in NyFormWidget.init.
Example:
@override
get init => () async {
final hobbies = await api.fetchHobbies();
return {
"hobbies": define(options: hobbies),
"price": define(value: "100"),
"favourite_color": "Blue", // plain values still work
};
};
Implementation
FieldDefinition define({dynamic value, dynamic options}) {
return FieldDefinition(value: value, options: options);
}