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

Changing options won't update UI. #81

Open
Jara92 opened this issue Mar 19, 2024 · 5 comments
Open

Changing options won't update UI. #81

Jara92 opened this issue Mar 19, 2024 · 5 comments
Assignees

Comments

@Jara92
Copy link

Jara92 commented Mar 19, 2024

I have MultiSelectDropDown inside BlocBuilder. It looks like this:

MultiSelectDropDown(
      controller: _controller,
      dropdownHeight: 200,
      onOptionSelected: (options) {},
      options: state.options,
    )

When I update state.options inside my Bloc, the UI remains the same - initial options are displayed. But this button put after the multi select works:

OutlinedButton(
     onPressed: (){
          _controller.setOptions(state.options);
     },
     child: Text("Dummy"))

Calling _controller.setOptions(state.options); inside BlocListener doesn't work either.

The problem occurs only in the newest version 2.1.4. Version 2.1.3 works fine for me.

@oi-narendra oi-narendra self-assigned this Mar 24, 2024
@Danyx1980
Copy link

I'm having the same issue, even calling widget.controller.clearSelection(option); inside onOptionRemoved doesn't update the UI, but does update the selectedOptions list.

@Istiak-Ahmed78
Copy link

Istiak-Ahmed78 commented Apr 21, 2024

I'm facing the same issue. 😞. Need fix

@JeromeTseng
Copy link

Dude,I got the same question,but i have an idea. I use UniqueKey to force update, and it works.
image
image

@mvitoriapereirac
Copy link

Dude,I got the same question,but i have an idea. I use UniqueKey to force update, and it works.
image
image

That was really helpful! Thanks. Could you explain a bit further why does it work?

@JeromeTseng
Copy link

Dude,I got the same question,but i have an idea. I use UniqueKey to force update, and it works.
image
image

That was really helpful! Thanks. Could you explain a bit further why does it work?

I'm sorry to reply to you so late, this involves a UI reuse problem, we updated some options in the dropdown, expecting it to take effect and update the UI, but flutter didn't do this and reused the last UI, if you use UniqueKey, it signifies, every UI rendering has to be redrawn, so your new options will take effect and render on the screen, I don't know if I understand it right

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

6 participants