Hey, it seems I can’t have this construction.. ```...
# compose
j
Hey, it seems I can’t have this construction..
Copy code
Text(
    text = text,
    modifier = Modifier.padding(top = 12.dp),
    textStyle = style,
)
I get the error
Copy code
None of the following functions can be called with the arguments supplied: 
public fun Text(text: AnnotatedString, 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 = ..., inlineContent: Map<String, InlineTextContent> = ..., onTextLayout: (TextLayoutResult) -> Unit = ..., style: TextStyle = ...): Unit defined in androidx.compose.material
public fun Text(text: String, modifier: Modifier = ..., color: Color = ..., fontSize: TextUnit = ..., fontStyle: FontStyle? = ..., fontWeight: FontWei
Any way to fix it ?
z
Yes: the error message tells you there’s no parameter named
textStyle
. It’s called just
style
.
j
thanks for pointing I am dumb. I lost half an hour on this.
z
Kotlin’s error messages for this are super hard to parse. It would be nice if they gave some hints based on type matching or something.
I probably would have missed it too except that I always forget what this parameter is called and keep typing it wrong myself 🙈
c
Yeah. This happens to me all the time. WHen there are so many args it is hard to tell whats going on without being super intimidated by the error. lol
j
Would It be nice to have those bunch of parameters incapsulated in a TextModifier or something similar ?
235 Views