解決方法
Optinアノテーションを用いる.
エラーメッセージについて
「This material API is experimental and is likely to change or to be removed in the future」:このマテリアルAPIは試験版で,将来的に変化する可能性や取り除かれる可能性がある.
例)アプリのトップアプリバーとして,テキストを中央配置したい.
@Composable
fun TopAppBar(modifier: Modifier = Modifier) {
CenterAlignedTopAppBar(
title = {
Text(
text = stringResource(R.string.app_name)
)
},
modifier = modifier
))
}
@OptIn(ExperimentalMaterial3API::class)
@Composable
fun TopAppBar(modifier: Modifier = Modifier) {
CenterAlignedTopAppBar(
title = {
Text(
text = stringResource(R.string.app_name)
)
},
modifier = modifier
)
}
@OptIn?
The Kotlin standard library provides a mechanism for requiring and giving explicit consent to use certain API elements. This mechanism allows library authors to inform users about specific conditions that require opt-in, such as when an API is in an experimental state and is likely to change in the future.
「Kotlin標準ライブラリは、特定のAPI要素を使用するために、明示的な同意を要求し、与えるためのメカニズムを提供する。このメカニズムにより、ライブラリの作者は、APIが実験的な状態にあり、将来的に変更される可能性がある場合など、オプトインを必要とする特定の条件についてユーザーに通知することができます。」という意味から、@Optinアノテーションを用いることで、将来的に変更が生じるAPIを使用することができるという認識である。