u2gilles
u2gilles

Reputation: 7383

Jetpack compose "Text" function deprecated (1.0.0-alpha09)

(config: compose_version = '1.0.0-alpha09' kotlin_version = "1.4.21")

The Jetpack Composable function "Text" is deprecated

Text( // <===== Strikethrough in Android Studio
    text = "Anna"
)

but I can't figure out how to replace it. The doc says to replace by ... Text

@Deprecated(
    message = "Use androidx.compose.material.Text for a high level Text component that " +
        "consumes theming information, or androidx.compose.foundation.text.BasicText for a basic " +
        "unopinionated component that does not have default theming",
    replaceWith = ReplaceWith(
        "Text(text, modifier, color, fontSize, fontStyle, fontWeight, fontFamily, " +
            "letterSpacing, textDecoration, textAlign, lineHeight, overflow, softWrap, maxLines, " +
            "onTextLayout, style)",
        "androidx.compose.material.Text"
    )
)

Upvotes: 1

Views: 967

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 199805

Change your androidx.compose.foundation.Text import to

import androidx.compose.material.Text

to use the non-deprecated Material version of Text, which is the drop in replacement for what Text did in previous alphas.

Upvotes: 5

Related Questions