The Code A is the source code of Android Studio.
The Code B is from the offical sample project here.
I can't understand fully why the author can pass these paramters LocalContentAlpha provides ContentAlpha.medium
to the function CompositionLocalProvider((vararg values: ProvidedValue<*>, ...)
.
You know that we separate paramters with comma normally.
Code A
@OptIn(InternalComposeApi::class)
fun CompositionLocalProvider(vararg values: ProvidedValue<*>, content: @Composable () -> Unit) {
currentComposer.startProviders(values)
content()
currentComposer.endProviders()
}
Code B
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(
id = R.string.article_post_min_read,
formatArgs = arrayOf(
metadata.date,
metadata.readTimeMinutes
)
),
style = typography.caption
)
}
from How can I pass paramters to the fun CompositionLocalProvider(vararg values: ProvidedValue<*>,...) in Android Studio?
No comments:
Post a Comment