rememberPainterDominantColorState

fun rememberPainterDominantColorState(defaultColor: Color = MaterialTheme.colorScheme.primary, defaultOnColor: Color = MaterialTheme.colorScheme.onPrimary, density: Density = LocalDensity.current, layoutDirection: LayoutDirection = LocalLayoutDirection.current, cacheSize: Int = 0, coroutineContext: CoroutineContext = Dispatchers.Default, isSwatchValid: (Palette.Swatch) -> Boolean = { true }, builder: Palette.Builder.() -> Unit = {}): DominantColorState<Painter>

Wrapper around rememberDominantColorState that uses PainterLoader to load the image.

Return

A DominantColorState which can be used to generate a dominant color from a Painter.

Parameters

defaultColor

The default color, which will be used if Palette.generate fails.

defaultOnColor

The default color to use on defaultColor.

density

The Density used for drawing the Painter as ImageBitmap.

layoutDirection

The LayoutDirection used for drawing the Painter as ImageBitmap.

cacheSize

The size of the LruCache used to store recent results. Pass 0 to disable.

coroutineContext

The CoroutineContext used to launch the coroutine.

isSwatchValid

A lambda which allows filtering of the calculated Palette.Swatch.

builder

A lambda which allows filtering of the calculated Palette.Builder used to generate the Palette.

See also