Kotlin Coroutines Cheat Sheet

Suspending functions, scopes, and flows

Last Updated: November 21, 2025

Core Concepts

Construct Use
suspend fun Asynchronous work
launch Start coroutine
async Return Deferred
Flow Stream values

Commands

GlobalScope.launch
Start background work
withContext(Dispatchers.IO)
Switch dispatcher
flow.collect
Consume streaming data

Advice

Avoid `GlobalScope`, handle exceptions with `CoroutineExceptionHandler`, and cancel child jobs with parent scope.

💡 Pro Tip: Use `CoroutineScope` tied to lifecycle and prefer `launch` for fire-and-forget tasks.
← Back to Programming Languages | Browse all categories | View all cheat sheets