Hi, how can I get screen size as Dp/float for Android & IOS targets with Compose Multiplatform?
Need some alternative to
LocalConfiguration
because I need size synchronously and some variants like
BoxWithConstraints
is not applicable.
i
Ivan Matkov
09/12/2023, 7:11 AM
It's platform specific, so you have to use expect actual.
For ios/desktop I recently added this way to do that:
LocalWindowInfo.current.containerSize
It's experimental now and will be available in the next release
👍 1
r
Roland
09/12/2023, 8:51 AM
You can use also
.onSizeChanged()
for the parent container.
i
Ivan Matkov
09/12/2023, 8:57 AM
In most cases yes: use modifier callbacks like
onGloballyPositioned
on root element and remember size for usage in your calculations.
In this case it isn't really "synchronous" way + there is an issue with not full screen compose canvas (currently there are a few more issues with not full screen compose, but it's another story)