Flutter : Filterchip not updating initial value as checked in form

502 views Asked by At

FormBuilder is not displaying the initial provided list as the checked values in the form. Although when form is submitted, initial provided list can be seen as the value of its chip attribute.

FormBuilderFilterChip(
                      attribute: "strAttr",
                      initialValue: ['abc', 'def'],
                      options: ['xyz', 'pqr']
                          .map((e) => FormBuilderFieldOption(
                          value: e,
                          child: Text("$e")
                      )).toList(),
                    ),

When form is loaded its showing as xyz, pqr values only and not adding initial values

without selecting any value on form if form is submitted, on printing

print(map['strAttr']);
[abc, def]

As per my understanding, When form is loaded 'xyz', 'pqr', 'abc', 'def' should get displayed on form with 'abc' and 'def' values as already checked in form.

Please let me know if its getting wrong with understanding, or how can this be achieved

Thanks !!!

1

There are 1 answers

0
Noorus Khan On

After 2-3 hour of struggle, figured it out, option list should also include initial list as well, and initial list values will be checked by default.

options: ['xyz', 'pqr', 'abc', 'def']