If I convert a `Color` value to `Int` (using `toAr...
# compose
n
If I convert a
Color
value to
Int
(using
toArgb()
) so I can save it in Datastore, how would I then convert the
Int
back to Jetpack Compose
Color
?
s
maybe
Color.valueOf(theIntValue)
?
n
Thanks but I can't write
Color.valueOf
... The option is not available.
r
There’s a
Color(Int)
function for this
You can also
Color(color.toULong() shl 32)
😄
f
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]mmonMain/kotlin/androidx/compose/ui/graphics/Color.kt?q=color @Stable fun *Color*(/*@*Color*Int*/ color: Int): Color { return *Color*(value = color.toULong() shl 32) }
n
Cool, thank you! 😊
r
You could also save it as `ULong`/`Long` since that’s how a
Color
is stored internally
👍 1
733 Views