-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: null check operator used on a null value #3447
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,51 +171,46 @@ class MemoriesPageState extends State<MemoriesPage> with AutomaticKeepAliveClien | |
| (() async { | ||
| final provider = context.read<MemoriesProvider>(); | ||
| await provider.init(); | ||
| if (!mounted) return; | ||
|
|
||
| // Apply the date-based default filter | ||
| _applyFilter(_currentFilter); | ||
|
|
||
| // Mark initial load as complete | ||
| if (mounted) { | ||
| setState(() { | ||
| _isInitialLoad = false; | ||
| }); | ||
| } | ||
| setState(() { | ||
| _isInitialLoad = false; | ||
| }); | ||
|
|
||
| if (!mounted) return; | ||
| final unreviewedMemories = provider.unreviewed; | ||
| final unreviewed = provider.unreviewed; | ||
| final home = context.read<HomeProvider>(); | ||
| if (unreviewedMemories.isNotEmpty && home.selectedIndex == 2) { | ||
| _showReviewSheet(context, unreviewedMemories, provider); | ||
|
|
||
| if (unreviewed.isNotEmpty && home.selectedIndex == 2) { | ||
| _showReviewSheet(context, unreviewed, provider); | ||
| } | ||
| }).withPostFrameCallback(); | ||
| } | ||
|
|
||
| void _applyFilter(FilterOption option) { | ||
| setState(() { | ||
| _currentFilter = option; | ||
| if (!mounted) return; | ||
|
|
||
| switch (option) { | ||
| case FilterOption.interesting: | ||
| _filterByCategory(MemoryCategory.interesting); | ||
| MixpanelManager().memoriesFiltered('interesting'); | ||
| break; | ||
| case FilterOption.system: | ||
| _filterByCategory(MemoryCategory.system); | ||
| MixpanelManager().memoriesFiltered('system'); | ||
| break; | ||
| case FilterOption.all: | ||
| _filterByCategory(null); // null means no category filter | ||
| MixpanelManager().memoriesFiltered('all'); | ||
| break; | ||
| } | ||
| }); | ||
| } | ||
| MemoryCategory? category; | ||
| switch (option) { | ||
| case FilterOption.interesting: | ||
| category = MemoryCategory.interesting; | ||
| MixpanelManager().memoriesFiltered('interesting'); | ||
| break; | ||
| case FilterOption.system: | ||
| category = MemoryCategory.system; | ||
| MixpanelManager().memoriesFiltered('system'); | ||
| break; | ||
| case FilterOption.all: | ||
| category = null; // null means no category filter | ||
| MixpanelManager().memoriesFiltered('all'); | ||
| break; | ||
| } | ||
|
|
||
| void _filterByCategory(MemoryCategory? category) { | ||
| if (!mounted) return; | ||
|
|
||
| setState(() { | ||
| _currentFilter = option; | ||
| _selectedCategory = category; | ||
| }); | ||
|
|
||
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two separate
setStatecalls here, one inside_applyFilterand another one here to set_isInitialLoad. This is inefficient as it causes two rebuilds. After applying the suggested change to_applyFilterto accept a callback, you can combine these into a single state update.