What is 'foldIn' and 'foldOut' of Modifier??
# compose
c
What is 'foldIn' and 'foldOut' of Modifier??
l
It's like
Iterable.fold
but Modifier version. When you construct a Modifier chain using
then
or whatever its wrapper like
Modifier.size
, the element at the front is called
outer
, while at the back is
inner
. So
foldIn
iterates from the first to the last, the other one backwards.
Copy code
Modifier
    .size
    .padding
    .background
    .foldIn(Unit) { _, element ->
        println(element::class.simpleName)
    }
will print
Copy code
SizeElement
PaddingElement
BackgroundElement
c
When do you use foldIn and foldOut?
l
Probably never. It's like something that is used for internal stuff.
d
378 Views