返回顶部
K

Kotlin

Build robust Android and multiplatform apps with Kotlin idioms, coroutines, and null safety.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.1
安全检测
已通过
1,511
下载量
2
收藏
概述
安装方式
版本历史

Kotlin

## Quick Reference | Topic | File | |-------|------| | Null safety operators and patterns | `nullsafety.md` | | Coroutines, flows, structured concurrency | `coroutines.md` | | Collections, sequences, data classes | `collections.md` | | Scope functions, extensions, sealed classes | `idioms.md` | | Java interop and common Kotlin mistakes | `interop.md` | | Android lifecycle, Compose state | `android.md` | | Delegation, inline, reified, multiplatform | `advanced.md` | ## Critical Rules ### Null Safety - `!!` asserts non-null — crashes on null, use only when you've already checked - Platform types from Java are risky — add null checks or use `@Nullable`/`@NonNull` annotations - Elvis with `return`/`throw` for early exit — `val name = user?.name ?: return` ### Coroutines - `viewModelScope` auto-cancels on ViewModel clear — don't use `GlobalScope` in Android - Structured concurrency: child coroutine failure cancels parent — use `supervisorScope` to isolate - `StateFlow` needs initial value and never completes — `SharedFlow` for one-shot events - Inject dispatchers for testability — don't hardcode `Dispatchers.IO` ### Collections & Data Classes - `first()` throws on empty — use `firstOrNull()` for safe access - Only constructor properties in `equals`/`hashCode` — body properties ignored - `mutableStateListOf` for Compose — wrapping `mutableListOf` in state won't track changes ### Scope Functions & Extensions - Don't nest scope functions — readability drops fast, extract to named functions - Extensions are resolved statically — not polymorphic, receiver type matters at compile time ### Android/Compose - `repeatOnLifecycle(STARTED)` for flow collection — `launchWhenStarted` is deprecated - `remember` survives recomposition only — use `rememberSaveable` for config changes - `collectAsStateWithLifecycle` is the gold standard — lifecycle-aware + Compose state ### Java Interop - `==` is structural equality in Kotlin — `===` for reference, opposite of Java - SAM conversion only for Java interfaces — Kotlin interfaces need explicit `fun interface` - `@JvmStatic`, `@JvmOverloads`, `@JvmField` for Java-friendly APIs

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 kotlin-1776329184 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 kotlin-1776329184 技能

通过命令行安装

skillhub install kotlin-1776329184

下载 Zip 包

⬇ 下载 Kotlin v1.0.1

文件大小: 7.16 KB | 发布时间: 2026-4-17 14:59

v1.0.1 最新 2026-4-17 14:59
Initial release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部