值得在商业应用程序中使用 OptIn 吗?

问题描述 投票:0回答:1

现在我正在编写我的 Android 应用程序,我将在 Google Play 上发布该应用程序。我使用 compose 来实现 ui。

TopAppBar
元素需要使用
OptIn
注释,因为它标有
ExperimentalMaterial3Api
,表明
This material API is experimental and is likely to change or to be removed in the future

@ExperimentalMaterial3Api
@Composable
fun TopAppBar(
    title: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    navigationIcon: @Composable () -> Unit = {},
    actions: @Composable RowScope.() -> Unit = {},
    windowInsets: WindowInsets = TopAppBarDefaults.windowInsets,
    colors: TopAppBarColors = TopAppBarDefaults.topAppBarColors(),
    scrollBehavior: TopAppBarScrollBehavior? = null
) {
@RequiresOptIn(
    "This material API is experimental and is likely to change or to be removed in" +
        " the future."
)
@Retention(AnnotationRetention.BINARY)
annotation class ExperimentalMaterial3Api

那么值得在商业应用程序中使用

OptIn
吗?或者最好使用一些替代方案来避免潜在的问题?

android kotlin android-jetpack-compose
1个回答
0
投票

RequiresOptIn
表示 API 很脆弱并且可能会发生变化。但是,底层 API 的任何更改都不会影响您的实时用户。仅当您向其发布更新时,它们才会受到影响。但需要考虑的一件事是,
RequiresOptIn
的使用具有传染性,这意味着它的所有用法都需要选择加入。因此,如果您打算很少使用它并且没有好的替代方案,我会说使用它,因为这样您的代码将受到更少的影响,并且当您最终要替换时,将来的技术债务也会减少它有一些稳定的API。我会说如果可能的话避免它,但不要因此而被阻止。 GTM 比次要的技术考虑更重要,尤其是对于独立开发者而言。

© www.soinside.com 2019 - 2024. All rights reserved.