Hi, what does `with(LocalDensity.current){sizeDp.t...
# compose
m
Hi, what does
with(LocalDensity.current){sizeDp.toPx()}
really do?
f
You can look at the implementation
m
I know, but what is the effect of calling Dp.toPx() inside
with(){}
?
f
You can't call it otherwise. You have to be in
Density
context (
this is Density
) to access this conversion extension function. You could also do
LocalDensity.current.run { sizeDp.toPx() }
❤️ 1
It's because this extension function is defined in
Density
interface so it has two receivers (contexts). One is
Density
and one is
Dp
defined on the function
❤️ 1