Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
How do I pass the onClick parameter in this one?

This is my OTP screen function to receive and read OTP.
The function has the 2 parameters as shown,

fun OTPScreen(
    navController : NavController,
    onClick: (mobileNum: String,otp: String) -> Unit,
)

This is my navhost function that navigates to the OTP screen.
Can someone tell me how do I pass the onClick parameter in this case?

composable(
    route = Screen.Otpscreen.route,
) {  
    OTPScreen(navController = navController, onClick = (" "))
}

I'm new to jetpack and functions are always confusing.
Let me know if I need to elaborate further.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I'm not familiar with compose but assuming it works like any other kotlin you could write it like this

OTPScreen(navController = navController, onClick = {mobileNum, otp ->
    //your code here
})

as noted by Karsten Gabriel, this can also be written shorter as

OTPScreen(navController) { mobileNum, otp -> 
  //your code here
}

Or, if you want to use an existing function like

fun myFunction(mobileNum: String, otp: String) {
    //your code here
}

for example you can use that like

OTPScreen(navController = navController, onClick = ::myFunction)
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda