Browsing Jetpack Compose samples
Anton Shilov
Posted on July 1, 2021
Problem
While writing apps with Jetpack Compose you can always Cmd+Click
on a library function to check their sources and comments. And often you can find a link to the sample code with an example of usages for that function. Unfortunately, sample code is not published together with the Jetpack Compose library so you cannot browse them.
Jetpack Compose has two kinds of samples. The API samples - small examples of api usages, and sample apps repo on github. In this post we're talking about API samples.
Easy Solution
All Jetpack Compose sources are open and published as a part of the AndroidX repo. We can quickly find sample code using Android Code Search website.
- Copy sample name from the sources
- Open https://cs.android.com in the browser
- Search for the sample code
Better solution
Keeping a browser tab open and manually copying function name is quite a hassle. We can do better, we can automate it! And CodeSearch plugin can help us with that. It allows us to launch search queries right from the IDE, and we can add a custom search engine.
- Install Code Search plugin https://plugins.jetbrains.com/plugin/12578-codesearch
Add Android Code Search engine to plugin settings(IDE restart required).
Name: Android CS
Url: https://cs.android.com/search?q=lang:kotlin usage:
Hope you found this post useful 😄. You can follow me to get the latest news about Compose.
Posted on July 1, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.