Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!