Fix: asyncListCallback called at initState#180
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesAsync Load and Filter Separation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/searchable_listview.dart`:
- Around line 904-909: The catch block in _asyncInitialList calls setState to
set asyncError without checking mounted, which can throw if the widget was
disposed during the prior await; fix by guarding the state update with the
widget's mounted flag (e.g., return early if not mounted or only call setState
when mounted) so the assignment to asyncError occurs only when the State is
still mounted.
- Around line 900-903: The code currently treats a null result from
asyncListCallback() as an empty list; change the logic in the async load path
(where initialData is assigned) to detect a null return from asyncListCallback
and set the error state instead of populating asyncListResult — e.g., after
calling asyncListCallback(), if initialData == null set the error flag/state and
ensure widget.errorWidget will be displayed, otherwise assign initialData to
asyncListResult; update any related state variables and triggers used by the
rendering logic so the error branch (widget.errorWidget) runs when initialData
is null.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 639fcabd-105a-4bfe-b44a-e5e7f875a6fc
📒 Files selected for processing (2)
example/lib/widgets/async_searchable_listview.dartlib/searchable_listview.dart
Closes #179.
The SearchableList.async now stores the asyncListCallback result and transmit it as an argument of asyncListFilter as expected.
The example is updated to show this behavior.
Summary by CodeRabbit