android / android/snippets

Wrong example: Basic list-detail layout (custom Scene and strategy)

Open
#841 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
1.1k
Forks
419
Avg merge
3d 18h
Merged PRs (30d)
28

Description

https://github.com/android/snippets/blob/8fb2abd59e6a3608741f914367867ed37a58aa0e/compose/snippets/src/main/java/com/example/compose/snippets/navigation3/scenes/ScenesSnippets.kt#L127

https://github.com/android/snippets/blob/8fb2abd59e6a3608741f914367867ed37a58aa0e/compose/snippets/src/main/java/com/example/compose/snippets/navigation3/scenes/ScenesSnippets.kt#L128

The lines referenced above:
```
val detailEntry =
entries.lastOrNull()?.takeIf { it.metadata.contains(DetailKey) } ?: return null
val listEntry = entries.findLast { it.metadata.contains(ListKey) } ?: return null
```

are wrong. metadata uses String as a key, so it should be:
```
val detailEntry =
entries.lastOrNull()?.takeIf { it.metadata.contains(DetailKey.toString()) } ?: return null
val listEntry = entries.findLast { it.metadata.contains(ListKey.toString()) } ?: return null
```

Using `androidx.navigation3:navigation3-runtime:1.1.0-beta01`.

Contributor guide

Open the contributing guide

Research direction

Open compose/snippets/src/main/java/com/example/compose/snippets/navigation3/scenes/ScenesSnippets.kt at lines 127-128 and review how metadata is keyed in the Basic list-detail layout example. Update the two membership checks to use the string form of DetailKey and ListKey, then verify the snippet with navigation3-runtime:1.1.0-beta01.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.