Easy way to convert from Dp to pixel? I'm trying t...
# compose
m
Easy way to convert from Dp to pixel? I'm trying to debug some screen
Copy code
with(LocalDensity.current) {
// code here, Dp interface will have the extension .toPx()
}
m
there is an extension already on Android but for desktop I have these
Copy code
@Composable
fun Dp.toPx() = with(LocalDensity.current) { this@toPx.toPx() }

@Composable
fun Int.toDp() = with(LocalDensity.current) { this@toDp.toDp() }