Kotlin & Android Kotlin 2.0 / Jetpack Compose / Android
Kotlin & Android Quick Reference
Essential Kotlin null-safety, data/sealed classes, Jetpack Compose state & lists, ViewModel/Coroutines, Room DAO, and Android build commands.
val name: String?; @Composable; StateFlow; viewModelScope.launch
Core Kotlin & Android Cheat Sheet
| Concept | Syntax / Command |
|---|---|
| Immutable / mutable binding | val count = 0 vs var count = 0 |
| Safe call & Elvis fallback | val label = user?.name ?: "Guest" |
| Data class copy | state.copy(isLoading = false) |
| Compose remembered state | var query by remember { mutableStateOf("") } |
| Efficient scrollable list | LazyColumn { items(list, key = { it.id }) { ... } } |
| Lifecycle-safe coroutine | viewModelScope.launch { ... } |
| Offload I/O off UI thread | withContext(Dispatchers.IO) { ... } |
| Build Play Store bundle | ./gradlew bundleRelease |