multiselect_formfield
multiselect_formfield copied to clipboard
Initial Value is causing error.
The method '[]' was called on null.
Receiver: null
Tried calling: []("display")
I am using hardcoded list to test but its not working.
MultiSelectFormField(
title: Text(
"Title Of Form",
style: TextStyle(fontSize: 16),
),
dataSource: [
{
"display": "Running",
"value": "Running",
},
{
"display": "Climbing",
"value": "Climbing",
},
],
textField: "display",
valueField: 'value',
okButtonLabel: 'OK',
cancelButtonLabel: 'CANCEL',
hintWidget: Text('Please choose one or more'),
initialValue: [
{
"display": "Running",
"value": "Running",
},
],
onSaved: (value) {
if (value == null) return;
setState(() {
// _selectedCategory = value;
});
},
),
You should only set a List of values to initialValue, and not a List containing each display-value pair. Try setting the initialValue to ["Running"]