Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Value is causing error. #45

Open
MuhammadAliKust opened this issue Oct 12, 2021 · 1 comment
Open

Initial Value is causing error. #45

MuhammadAliKust opened this issue Oct 12, 2021 · 1 comment

Comments

@MuhammadAliKust
Copy link

MuhammadAliKust commented Oct 12, 2021

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants