How to get screen width and height for Ios and And...
# compose-ios
s
How to get screen width and height for Ios and Android in common module in compose Multiplatform? see more detail here: https://github.com/JetBrains/compose-multiplatform/discussions/3225
a
a possible solution would be using the
OnGloballyPositionedModifier
modifier, there was this option but not sure if already works
a
With the help of expect/actual you can use
LocalConfiguration.current.screenWidthDp
on Android and
LocalWindowInfo.current.containerSize
on non-Android (starting from 1.5.10-beta01).
👍🏻 1
👍 1
a
I’d recommend against
LocalConfiguration.current.screenWidthDp
on Android - due to insets it can be smaller than the actual window size, and due to density rounding it can be off by at least a pixel from the true actual window size.
WindowMetricsCalculator.computeCurrentWindowMetrics
is the way to go.
👍 1
961 Views