gpt4 book ai didi

android - 如何预览具有非空类型参数的可组合项?

转载 作者:行者123 更新时间:2023-12-03 08:10:08 25 4
gpt4 key购买 nike

@Composable
fun VerifyScreen(
email: String,
navigator: DestinationsNavigator
) {
// ..

}


@Composable
@Preview
fun VerifyScreenPreview() {
VerifyScreen("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="740d1b013406115a150311071b1911" rel="noreferrer noopener nofollow">[email protected]</a>", null)
}

Null can not be a value of a non-null type DestinationsNavigator

当然,您可以通过添加问号来更改类型,但如果这不是一个选项怎么办?

navigator: DestinationsNavigator?

最佳答案

您可以使用库提供的EmptyDestinationsNavigator

@Composable
@Preview
fun VerifyScreenPreview() {
VerifyScreen("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="95ecfae0d5e7f0bbf4e2f0e6faf8f0" rel="noreferrer noopener nofollow">[email protected]</a>", EmptyDestinationsNavigator)
}

关于android - 如何预览具有非空类型参数的可组合项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71066210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com