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

Selected Values Cannot Be Modified Using the Bloc Framework #40

Open
neilmahaseth opened this issue May 13, 2021 · 0 comments
Open

Selected Values Cannot Be Modified Using the Bloc Framework #40

neilmahaseth opened this issue May 13, 2021 · 0 comments

Comments

@neilmahaseth
Copy link

neilmahaseth commented May 13, 2021

I wanted to set the selected value of MultiSelectDialogField from my bloc code by binding it to the initialValue parameter but on looking at source code I found that the internal reference was only being updated in the initState

 void initState() {
     super.initState();
     if (widget.initialValue != null) {
       _selectedItems.addAll(widget.initialValue!);
     }
  }   

Which makes it imposible to use it to update the selected value on state change triggered on changing the initialValue parameter from my bloc code.

I was able to fix the issue by modifying the build method of MultiSelectDialogField

 Widget build(BuildContext context) {
    if (widget.initialValue != null) {
      _selectedItems=widget.initialValue!;
    }

If there is any other way externally modify (using the bloc architecture) the selected values of MultiSelectDialogField without altering the code please let me know.

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

1 participant