Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

330
Vistas
What is this "provides" syntax in this kotlin jetpack compose code sample?

What is the "provides" syntax in this code sample and what does it do?

LocalContentAlpha provides ContentAlpha.medium

It doesn't seem to be a standard kotlin keyword and I haven't had much luck googling for queries like "kotlin provides keyword" or "jetpack compose provides".

This shows up on the Jetpack Compose codelab, full snippet below.

@Composable
fun PhotographerCard() {
    Column {
        Text("Alfred Sisley", fontWeight = FontWeight.Bold)
        // LocalContentAlpha is defining opacity level of its children
        CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
            Text("3 minutes ago", style = MaterialTheme.typography.body2)
        }
    }
}

@Preview
@Composable
fun PhotographerCardPreview() {
    LayoutsCodelabTheme {
        PhotographerCard()
    }
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This is an example of an infix function:

Functions marked with the infix keyword can also be called using the infix notation (omitting the dot and the parentheses for the call).

As seen by the existence of the infix keyword on the method's documentation.

So the method could be called normally as LocalContentAlpha.provides(ContentAlpha.medium), but the infix notation allows for those extra syntax characters to be dropped.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda