Skip to content

Check listener state before set new value#23

Open
robzimpulse wants to merge 1 commit into
xsahil03x:mainfrom
robzimpulse:fix_error_when_no_listener
Open

Check listener state before set new value#23
robzimpulse wants to merge 1 commit into
xsahil03x:mainfrom
robzimpulse:fix_error_when_no_listener

Conversation

@robzimpulse
Copy link
Copy Markdown

@robzimpulse robzimpulse commented Jan 28, 2026

Description

Check ValueNotifier disposed state before set new value. Sometimes, the cancellation callback is triggered after closing the screen (pager were disposed) hence triggering exception.

Type of Change

  • [❌ ] ✨ New feature (non-breaking change which adds functionality)
  • [✅] 🛠️ Bug fix (non-breaking change which fixes an issue)
  • [❌] ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • [✅] 🧹 Code refactor
  • [❌] ✅ Build configuration change
  • [❌] 📝 Documentation
  • [❌] 🗑️ Chore

Summary by CodeRabbit

  • Refactor
    • Optimized state management efficiency to reduce unnecessary updates and improve application performance.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 28, 2026

Walkthrough

The PageFetcher class adds a setter override for the value property that guards state updates with a hasListeners check. Updates are prevented when no listeners are present; otherwise, the update delegates to the parent class.

Changes

Cohort / File(s) Summary
ValueNotifier Setter Guard
lib/src/page_fetcher.dart
Added value setter override in PageFetcher<Key, Value> that early-returns if hasListeners is false, preventing unnecessary state propagation when no listeners exist.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop, a check, a guard so keen,
No listeners? The value stays serene,
We skip the update, save the day,
In Notifier land, efficiency's the way!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: adding a listener state check before updating the value in the ValueNotifier.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant