Skip to content

Compose Utilities

Ghimpu Lucian Eduard edited this page Nov 21, 2022 · 1 revision

Compose Utilities

The library provides a series of utilities, we will highlight here some of the them.

EmptyPainter

As the name suggests, EmptyPainter is a Painter that uses Size.Unspecified to render nothing. This can be useful as a fallback Painter when you need an actual implementation (e.g. to cover null cases).

@Preview
@Composable
fun PreviewEmptyPainter() {
  Row {
    Icon(painter = EverliResources.Icons.User, contentDescription = null)
    Icon(painter = EmptyPainter, contentDescription = null)
    Icon(painter = EverliResources.Icons.Edit, contentDescription = null)
  }
}

ℹ️ Note that in the above sample, the EmptyPainter will still have a size of 24.dp because that's the minimum enforced sized by Icon:

// Default icon size, for icons with no intrinsic size information
private val DefaultIconSizeModifier = Modifier.size(24.dp)
Screenshot 2022-11-21 at 15 52 54

Clone this wiki locally