如何将当前填充应用于 Jetpack Compose 中的修改器?

How to get the current padding applied to a modifier in Jetpack Compose?

我正在将修饰符实例传递给这样的函数

@Composable
fun SomeComposable(modifier : Modifier) {
    
}

我想知道函数内传递给修饰符的当前填充。如何做到这一点?

@Composable
   fun SomeComposable(modifier : Modifier) {
       // val currentTopPadding = modifier.getTopPadding()
  }

我知道没有什么比 getTopPadding() 但我想要一个类似的或任何其他功能,如果有任何可以给我填充的功能

来自Adam Powell in Kotlin Slack Channel的回答:

No, you're not meant to be able to ask this. If you were able to and this practice were encouraged it would be prohibitively difficult to write UI code that composes with UI code written by others, or to combine libraries that are unaware of one another

This is why Android View padding is frighteningly complex - it permits querying padding and the set of things considered "padding" is unexpectedly large, and has to be for correctness

Padding is an instruction to compose's layout system to subtract available space from an element during measurement and to position the final measured element within a larger space. It is far from the only such instruction available, and app or library code can create their own as well.

这是他的回答 link