Is it a known problem with theming in `beta02`? My...
# compose
d
Is it a known problem with theming in
beta02
? My app can switch from light to dark, but not back. And I can't understand what happened with it. It worked before beta02. https://kotlinlang.slack.com/archives/CJLTWPH7S/p1615651080120600
hm,
Colors
objects are mutable (their fields are `var`s), and looks like my
LightColorPalette
singleton gets changed somewhere, but I don't see where. If I copy it before passing to
MaterialTheme
it works as expected
l
Yes, this is a known issue (https://issuetracker.google.com/issues/182635582) - for now calling
.copy()
before you pass it in is a workaround
👍 1
d
@Louis Pullen-Freilich [G] what's the reason for mutability in
Colors
? wouldn't it be better if it was a completely immutable class?
l
Yes typically immutability is good (and would help avoid issues like this) but in the case of colors there are very large performance benefits from having it mutable - it means that if you are animating one color (such as primary) then only components that are actually using that color will be recomposed, instead of every component in the application
👍 1
🙏 1