<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm" -->

---
title: Kotlin Flows in Android: A Clear Mental Model | daily.dev
description: A conceptual walkthrough of Kotlin Flow, StateFlow, and SharedFlow for Android development, using analogies like pipes and whiteboards to explain reactive...
canonical: https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Kotlin Flows in Android: A Clear Mental Model | daily.dev
og:description: A conceptual walkthrough of Kotlin Flow, StateFlow, and SharedFlow for Android development, using analogies like pipes and whiteboards to explain reactive...
og:url: https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm
og:image: https://api.daily.dev/og/posts/Ln8RFFWwM.png
og:image:alt: Kotlin Flows in Android: A Clear Mental Model
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Flows in Android: A Clear Mental Model

**[Medium](https://daily.dev/sources/medium_js)** · 6 min read · 0 upvotes · 0 comments

## Summary

A conceptual walkthrough of Kotlin Flow, StateFlow, and SharedFlow for Android development, using analogies like pipes and whiteboards to explain reactive streams. Covers cold flows, the mutable/read-only StateFlow pattern in ViewModels, when to use SharedFlow for one-off events, common flow operators (map, filter, debounce, distinctUntilChanged, flatMapLatest), and safely collecting flows in Jetpack Compose with collectAsStateWithLifecycle.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@sehajkahlon437/kotlin-flows-in-android-a-clear-mental-model-4f91919b122f>

## Questions this post answers

### When should I use StateFlow versus SharedFlow in an Android ViewModel?

Use StateFlow for data representing the current state of the screen, like loading indicators, search text, or error messages, since it always holds a value and replays it to new collectors. Use SharedFlow for one-off events, like a 'Profile saved' Snackbar, since it doesn't require an initial value and won't re-deliver old messages after a screen rotation.

_Developers deciding between state and event streams often compare real Android patterns like this on daily.dev._

### Why do ViewModels expose both a MutableStateFlow and a read-only StateFlow property?

This pattern, using a private _uiState MutableStateFlow and a public uiState StateFlow via asStateFlow(), keeps mutation confined to the ViewModel. The UI layer can only observe and react to the read-only version, preventing it from accidentally overwriting state directly and breaking the app's architecture.

_Android engineers refining ViewModel architecture patterns can dig into examples like this on daily.dev._

## Similar posts on daily.dev

- [Android Reactive Streams: EventBus, Rx, Kotlin Flow](https://daily.dev/posts/android-reactive-streams-eventbus-rx-kotlin-flow-iczy0yqg8) · ProAndroidDev · 5 upvotes · 1 comments
- [SharedFlow in Kotlin — A Simple Guide for Android Developers](https://daily.dev/posts/sharedflow-in-kotlin-a-simple-guide-for-android-developers-mv14qhbzq) · Medium · 0 upvotes · 0 comments
- [Mastering Coroutines and Flow in Android](https://daily.dev/posts/mastering-coroutines-and-flow-in-android-opgwyvoqn) · Medium · 0 upvotes · 0 comments
- [How Emissions Work in Kotlin Flows and Channels](https://daily.dev/posts/how-emissions-work-in-kotlin-flows-and-channels-uhe2jnnv3) · ProAndroidDev · 0 upvotes · 0 comments
- [Consuming SKIE Flows in SwiftUI](https://daily.dev/posts/consuming-skie-flows-in-swiftui-nxkwmuyhl) · Touchlab · 0 upvotes · 0 comments

---

Tags: [#android](https://daily.dev/tags/android), [#kotlin](https://daily.dev/tags/kotlin), [#jetpack-compose](https://daily.dev/tags/jetpack-compose)

[View this post on daily.dev](https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Kotlin Flows in Android: A Clear Mental Model","url":"https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm"},"datePublished":"2026-09-09T19:30:14.801Z","dateModified":"2026-09-09T19:32:28.666Z","description":"A conceptual walkthrough of Kotlin Flow, StateFlow, and SharedFlow for Android development, using analogies like pipes and whiteboards to explain reactive...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b0e096bc6839e7c9dfeffb29835ed17b?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b0e096bc6839e7c9dfeffb29835ed17b?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"android,kotlin,jetpack-compose","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Kotlin Flows in Android: A Clear Mental Model"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/kotlin-flows-in-android-a-clear-mental-model-ln8rffwwm#faq","mainEntity":[{"@type":"Question","name":"When should I use StateFlow versus SharedFlow in an Android ViewModel?","acceptedAnswer":{"@type":"Answer","text":"Use StateFlow for data representing the current state of the screen, like loading indicators, search text, or error messages, since it always holds a value and replays it to new collectors. Use SharedFlow for one-off events, like a 'Profile saved' Snackbar, since it doesn't require an initial value and won't re-deliver old messages after a screen rotation. Developers deciding between state and event streams often compare real Android patterns like this on daily.dev."}},{"@type":"Question","name":"Why do ViewModels expose both a MutableStateFlow and a read-only StateFlow property?","acceptedAnswer":{"@type":"Answer","text":"This pattern, using a private _uiState MutableStateFlow and a public uiState StateFlow via asStateFlow(), keeps mutation confined to the ViewModel. The UI layer can only observe and react to the read-only version, preventing it from accidentally overwriting state directly and breaking the app's architecture. Android engineers refining ViewModel architecture patterns can dig into examples like this on daily.dev."}}]}
```

