In the previous code , currentTopLevelDestination would be momentaril… #1685
+5
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
currentTopLevelDestination is null momentarily , causing the TopAppBar to flicker while navigating the top level destinations.
In short the problem lies here
The log statement above would confirm that while switching between the top level composables , the currentDestination is obtained as null at times , until it is not .
I dont have the exact reasoning as to why that is. My hypothesis is that since there is no "gate" between the
currentDestination
composable and thecurrentTopLevelDestination
,currentTopLevelDestination
reacts to everything that occurs tocurrentDestination
and perhapscurrentDestination
goes through a null while going from one destination to another.Solution
I just gated the
currentTopLevelDestination
with a remember .Before
After