Small Compose experiments, each with the why written down. Clearly labelled as learning in public — not a product.
A wrapping row built with the Layout composable: measure children, break to a
new line when the next one won't fit, place each one.
The wrapping maths is factored out into flowLayout(itemSizes, maxWidth, hGap, vGap),
a pure function — so the logic that's easy to get wrong (row height = tallest
item, an item wider than the container, the off-by-one gap on the last item) is
covered by 5 unit tests with no Compose runtime.
FlowRow(Modifier.fillMaxWidth()) {
tags.forEach { Chip(it) } // wraps across lines automatically
}rememberRecompositionCount() returns a live count of how many times its owner
composed. The demo screen renders two rows:
| Row | Param type | On unrelated parent recomposition |
|---|---|---|
UnstableRow |
List<String> — unstable to the compiler |
recomposes every time |
StableRow |
@Immutable Labels(List<String>) |
skipped when unchanged |
Tap "bump unrelated parent state" and watch the unstable counter climb while the stable one holds. That's the whole argument for stability annotations, made concrete.
./gradlew :app:assembleDebug # the demo app
./gradlew :app:testDebugUnitTest # the flowLayout tests
- A gesture component (
anchoredDraggableswipe-to-reveal) -
SubcomposeLayoutexperiment — measure-then-decide - Recomposition counts captured in a Macrobenchmark, not just on screen
-
Modifier.Nodecustom modifier vs the oldcomposed { }approach
Apache-2.0 · Chinmay Tayade · LinkedIn