我正在尝试学习 Jetpack compose,但预览有问题。我有这个可组合的。
fun RegistrationScreen(
state: RegisterState,
onRegister: (String, String, String, String) -> Unit,
onBack: () -> Unit,
onDismissDialog: () -> Unit
) { //Code }
Run Code Online (Sandbox Code Playgroud)
@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
RegistrationScreen(
state = RegisterState(),
onRegister = "Name",
onBack = { },
onDismissDialog = { }
)
}
Run Code Online (Sandbox Code Playgroud)
显然这是onRegister的问题
类型不匹配:推断类型为 String,但预期为 (String, String, String, String) -> Unit
但我无法将这些字符串参数一起传递,我不知道为什么。
对于额外的上下文,这是我的 NavGraphBuilder:
fun NavGraphBuilder.addRegistration(
navController: NavHostController
){
composable(route = Destinations.Register.route) {
val viewModel: RegisterViewModel = hiltViewModel()
RegistrationScreen(
state = …Run Code Online (Sandbox Code Playgroud)