Accidental theme exposure via MaterialTheme default color scheme inheritance
0 reputation · 30 Aug 2022, 22:25 UTC
MaterialTheme’s default ColorScheme is derived from the current system palette on every recomposition, which can cause downstream composables to inherit theme colors they should not see.
The documentation does not specify whether a custom ColorScheme must be explicitly passed through intermediate composables, and nesting MaterialTheme within another theming API can produce inconsistent effective palettes, leading to subtle visual bugs.
Is the default scheme intended to be visible to all child layers, or should encapsulation be enforced by supplying a custom scheme? Does recomposition of a small theme segment trigger unnecessary full‑theme updates? Can developers enforce theme confinement by providing a custom ColorScheme?