The output was right. The code was wrong — Compose Modifier order
John Kenedy | Make This Work
0:00 / 0:00
The output was right. The code was wrong — Compose Modifier order
9 просмотров · 23 часа назад
John Kenedy | Make This Work
27 подписчиков
9 просмотров · 23 часа назад
I shipped a component that looked perfect. Circular avatar, thin grey border, exactly the design. Then I read my own code:
Modifier
.clip(CircleShape)
.border(2.dp, outline)
border() has a second parameter:
fun Modifier.border(border: BorderStroke, shape: Shape = RectangleShape)
The default is RectangleShape. I was drawing a rectangular border — and the .clip() above it was cutting that rectangle into a circle before it
reached the screen. The picture was right. The reasoning behind it wasn't.
That's a worse kind of bug than one that breaks, because nothing tells
you. It survives review, it survives QA, and it breaks the day someone
reorders two lines or removes the clip.
In this video:
→ why Modifier is an ordered chain, not a bag of properties
→ clip() affects everything drawn after it, and nothing before
→ background() and border() BOTH default to RectangleShape
→ how to tell "right" from "right by accident"
WRITTEN VERSION, with a quiz
https://makethiswork.dev/lets-make-mo...
I stream Sunday to Friday, 19:00 WEST — studying Android and Kotlin out loud, not teaching. 45 minutes of real work, then a recap.
/ johnkenedymtw
MENTORSHIP
A small number of engineers at a time — architecture on your real
codebase, or interview prep for a role abroad.
https://makethiswork.dev/mentorship
#JetpackCompose #AndroidDev #Kotlin #ComposeUI #Android