Skip to content

Fixed setState issue in MacosPulldownButton#585

Merged
GroovinChip merged 1 commit into
macosui:devfrom
Abbas1Hussein:Fix-something
Oct 13, 2025
Merged

Fixed setState issue in MacosPulldownButton#585
GroovinChip merged 1 commit into
macosui:devfrom
Abbas1Hussein:Fix-something

Conversation

@Abbas1Hussein

Copy link
Copy Markdown
Contributor

🔄 Reopened PR

This replaces a previous PR that was closed due to a branch issue.
Reopening with a clean branch and the same fix applied.


🧩 Fix: avoid calling setState after dispose in MacosPulldownButton

When I used MacosPulldownButton, this error appeared during tests:

setState() called after dispose(): _MacosPulldownButtonState (lifecycle state: defunct, not mounted)

It happened because setState was called inside the navigator.push(...).then(...) callback after the widget was already disposed.

I fixed it by adding a mounted check before calling setState:

navigator.push(_pulldownRoute!).then<void>((_) {
  if (!mounted) return;
  setState(() => _pullDownButtonState = PulldownButtonState.enabled);
  _removeMacosPulldownRoute();
});

Thanks for your patience, I’ll be happy to make any additional changes if needed.

Fix setState() called after dispose in MacosPulldownButton

@GroovinChip GroovinChip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GroovinChip GroovinChip merged commit f5c6d6e into macosui:dev Oct 13, 2025
2 of 3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants