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

Fix: onChanged not invoked after first invocation #76

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

ravindrabarthwal
Copy link

In the custom_dropdown.dart, the didUpdateWidget method changes the selectedItemNotifier and selectedItemsNotifier to a new instance when the widget configuration is inconsistent.

This causes two problems, first if the end user supplied the controller then it will be overriden. Secondly, new instance is not required, and even if created should have attached the listeners to the the new instance.

This commit solves the problem by updating the earlier instance of the notifier to the new value via SchedulerBinding. Also, the two examples have been changed to use the stateful widget, which solves the current problem.

@karniv00l
Copy link

Indeed, 3.1.0 is broken, and this PR fixes it, thanks!

@AbdullahChauhan AbdullahChauhan added the bug Something isn't working label Jun 7, 2024
@AbdullahChauhan AbdullahChauhan self-requested a review June 7, 2024 12:47
@AbdullahChauhan
Copy link
Owner

Hey @ravindrabarthwal Thanks for the PR. Start reviewing this...
@karniv00l Thanks for confirming!

lib/custom_dropdown.dart Outdated Show resolved Hide resolved
lib/custom_dropdown.dart Show resolved Hide resolved
In the custom_dropdown.dart, the didUpdateWidget method changes the selectedItemNotifier
and selectedItemsNotifier to a new instance when the widget configuration is inconsistent.

This causes two problems, first if the end user supplied the controller then it will be overriden. Secondly, new instance is not
required, and even if created should have attached the listeners to the the new instance.

This commit solves the problem by updating the earlier instance of the notifier to the new value via SchedulerBinding.
Also, the two examples have been changed to use the stateful widget, which solves the current problem.
@AbdullahChauhan AbdullahChauhan merged commit 3416cff into AbdullahChauhan:master Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants