cetorres / multiselect_formfield

A Flutter package that provides a multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.
BSD 3-Clause "New" or "Revised" License
72 stars 59 forks source link

Initial Value is causing error. #45

Open MuhammadAliKust opened 3 years ago

MuhammadAliKust commented 3 years ago
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;
                            });
                          },
                        ),
tsgregoryv commented 2 years ago

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"]