AnnotatedStringBuilder

Builder for creating AnnotatedString instances with styled text.

This is a top-level class (rather than nested inside AnnotatedString) to allow actual typealias AnnotatedString = PlatformAnnotatedString on Compose UI platforms, working around a Kotlin limitation where nested classes of expect classes cannot be resolved through typealiases from consuming modules.

Corresponds to androidx.compose.ui.text.AnnotatedString.Builder.

actual class AnnotatedStringBuilder(val mutableNodeList: MutableList<AnnotatedString.Node> = mutableListOf())(source)

Builder for AnnotatedString.

Uses a tree of AnnotatedString.Nodes where withStyle pushes/pops node levels, mapping 1:1 to nested HTML <span> tags in the rendered output.

Constructors

Link copied to clipboard
expect constructor(text: String)

Create an AnnotatedStringBuilder instance using the given String.

expect constructor(text: AnnotatedString)

Create an AnnotatedStringBuilder instance using the given AnnotatedString.

constructor(mutableNodeList: MutableList<AnnotatedString.Node> = mutableListOf())
actual constructor(text: String)

Create an AnnotatedStringBuilder instance using the given String.

actual constructor(text: AnnotatedString)

Create an AnnotatedStringBuilder instance using the given AnnotatedString.

Properties

Functions

Link copied to clipboard
expect fun append(text: AnnotatedString)
expect fun append(text: String)
actual fun append(text: AnnotatedString)
actual fun append(text: String)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
expect inline fun <R : Any> AnnotatedStringBuilder.withStyle(style: SpanStyle, block: AnnotatedStringBuilder.() -> R): R
actual inline fun <R : Any> AnnotatedStringBuilder.withStyle(style: SpanStyle, block: AnnotatedStringBuilder.() -> R): R
actual inline fun <R : Any> AnnotatedStringBuilder.withStyle(style: SpanStyle, block: AnnotatedStringBuilder.() -> R): R