(just creates ImageBitmap). In a composable context it’s easy to use the wrong one and cause excessive bitmap creations. Consider renaming one of them to be not so similar and making it more obvious from the name when to use which.
Hmm, actually, looking at this a bit more, I think maybe the fact it uses remember is intended to be a transparent implementation detail and is used purely for performance reasons, so maybe the
remember
prefix is not correct here.
jim
01/08/2021, 3:08 PM
I wonder if the actual bug is that
imageFromResource
doesn't do any caching, and they should both behave more similarly. Although it seems like we should provide apps with a way to load images from outside of a Composable call tree. Perhaps
cachedImageResource
for the variant that does remember caching? I'll bring it up with API council. Thanks for flagging.
o
orangy
01/08/2021, 4:29 PM
imageFromResource
is not composable, so it can be used for manual caching, e.g. an object with static resources. It looks like the semantic is fine, it’s just that names are confusing