-
Notifications
You must be signed in to change notification settings - Fork 138
Description
In which task and step of the codelab can this issue be found?
Navigate between screens with Compose
Describe the problem
Navigation does not work with the provided code for the call of passed functions without parameters () -> Unit
Steps to reproduce?
The tutorial tells me to add this code on onClick of the the button in SelectOptionScreen.kt:
...
Button(
modifier = Modifier.weight(1f),
enabled = selectedValue.isNotEmpty(),
onClick = onNextButtonClicked
) {
Text(stringResource(R.string.next))
}
...
But this is not working, at least on my setup. I know, that kotlin generally allows function calls without empty parenthesis if there are no parameters needed. But it seems to need empty parenthesis here.
Because if I add them here:
onClick = onNextButtonClicked()
it works like it should!
It took me hours to spot this. Even Gemini did not spot this error, neither did the compiler.
Versions
Android Studio version:
Build #AI-251.25410.109.2511.13752376
API version of the emulator:
API 36
Additional information
Include screenshots if they would be useful in clarifying the problem.