I have a generic composable that renders an error ...
# compose
b
I have a generic composable that renders an error message (text and icon) using the Material Theme’s 
error
 color.  Typically it should use 
error
 color for the text color and to tint the icon…. However, in some cases this composable may be called from a 
Surface()
 that has its (background) color set to the theme’s 
primaryColor
. In these cases, I’d want error composable to render with its background as the 
error
 color (and use 
onError
 for the text color and to tint the icon).  I’m wondering how to achieve this? One idea is to create a 
CompositionLocal
 that is consumed by my 
ErrorMessage
 composable, and I can set its values appropriately in the 
Surface
 to control how errors will appear in that surface.  Does that seem like the right approach? Is there another way to accomplish this?