multi_select_flutter icon indicating copy to clipboard operation
multi_select_flutter copied to clipboard

Set State not working with MultiSelectBottomSheetField

Open Matthew-828 opened this issue 4 years ago • 4 comments

Hi, I'm using MultiSelectBottomSheetField with other widgets that need setState like CheckboxListTile and Radio. When pressing the Radio button or checkBox ( or anything that is with setState ), it removes all the displaying item in the MultiSelectBottomSheetField. The variable still have the selected values but display all gone.

Matthew-828 avatar Jan 11 '22 03:01 Matthew-828

Hello,

I did try to reproduce this, but I'm not having the same problem. Can you provide a code example that reproduces the issue?

CHB61 avatar Jan 11 '22 23:01 CHB61

Hi Below is my code:

Under the stateful widget I declared the folowing variable. image

Inside my Stateful widget -> body -> Form, I have a Future builder where future is "_getGroup", the variable declared in the first image to get API data. If snapshot has data, I convert the json data into list so that I can map it to MultiSelectItem. Then I do the MultiSelectBottomSheet as usual. image

For your information, the ReportInfo class is as follows: image

and this is how I get the _list image

When I select the data, it looks like this: image

but when I click on Radio / CheckBoxListTile, the chipDisplay is gone

Matthew-828 avatar Jan 12 '22 02:01 Matthew-828

I'm facing the same error when I use filtering search, it returns me setState error and clear all my selection.

GabrielLana avatar Jan 31 '22 12:01 GabrielLana

Add the parameter key: GlobalKey() to your MultiSelectBottomSheetField and the setState will work

Source: https://github.com/CHB61/multi_select_flutter/issues/12#issuecomment-1051216159

Muhammad-FlutterDev avatar Nov 05 '24 04:11 Muhammad-FlutterDev