Afeez Dosunmu
11/09/2024, 10:35 AMprivate fun Toolbar() {
TopAppBar(
title = { Text(text = "About Device") }
)
}
This is my import for Text
import androidx.compose.material3.Text
The Text
is underlined red and I have this error
Overload resolution ambiguity. All these functions match.
public fun Text(text: String, modifier: Modifier = ..., color: Color = ..., fontSize: TextUnit = ..., fontStyle: FontStyle? = ..., fontWeight: FontWeight? = ..., fontFamily: FontFamily? = ..., letterSpacing: TextUnit = ..., textDecoration: TextDecoration? = ..., textAlign: TextAlign? = ..., lineHeight: TextUnit = ..., overflow: TextOverflow = ..., softWrap: Boolean = ..., maxLines: Int = ..., minLines: Int = ..., onTextLayout: ((TextLayoutResult) → Unit)? = ..., style: TextStyle = ...): Unit defined in androidx. compose. material3
public fun Text(text: String, modifier: Modifier = ..., color: Color = ..., fontSize: TextUnit = ..., fontStyle: FontStyle? = ..., fontWeight: FontWeight? = ..., fontFamily: FontFamily? = ..., letterSpacing: TextUnit = ..., textDecoration: TextDecoration? = ..., textAlign: TextAlign? = ..., lineHeight: TextUnit = ..., overflow: TextOverflow = ..., softWrap: Boolean = ..., maxLines: Int = ..., minLines: Int = ..., onTextLayout: (TextLayoutResult) → Unit = ..., style: TextStyle = ...): Unit defined in androidx. compose. material3
any help with it ? ThanksRob Elliot
11/09/2024, 12:27 PMText(text = "About Device")
). The difference between them seems to be that one takes a parameter onTextLayout
which has type ((TextLayoutResult) → Unit)?
(a function, but can be null), defaulted to something, and one takes a parameter onTextLayout
which has type (TextLayoutResult) → Unit
(a function, but cannot be null) which is also defaulted.
You can probably resolve it by passing a value as onTextLayout
, either null
or {_ -> }
, but it seems an odd API design for Android.Rob Elliot
11/09/2024, 12:29 PMephemient
11/09/2024, 1:44 PMephemient
11/09/2024, 1:45 PMephemient
11/09/2024, 1:45 PMAfeez Dosunmu
11/09/2024, 1:55 PM