Is it possible to create a lambda based modifier for padding like
Modifier.padding { }
I have a padding value which animates and due to that
Modifier.padding(..)
created recompositions
👀 1
z
Zach Klippenstein (he/him) [MOD]
06/29/2024, 5:20 PM
Absolutely. Also note that PaddingValues is also an interface that can evaluate each individual value lazily.
m
Matthew Feinberg
07/02/2024, 12:03 AM
Wouldn't the padding affect the interior calculated dimensions and require a recomposition of children anyway? (Unless the padding on one side were to grow/shrink to exactly balance changes in the padding on the other side, in which case wouldn't
.offset { }
work just as well?)
(I feel like I must be missing something obvious here)
z
Zach Klippenstein (he/him) [MOD]
07/02/2024, 12:36 AM
Layout changes don’t trigger recomposition unless:
1. you’re using layout-based subcomposition, like BoxWithConstraints, or
2. You are writing into some state object from layout that you read in composition
m
Matthew Feinberg
07/02/2024, 12:38 AM
Ah, of course, I was mixing up the layout and composition phases. I should probably wait a few more minutes after waking up before using Slack 😅