@Adam Powell I was lazy. I only read the doc for the
update
param which says "The callback to be invoked after the layout is inflated.", so I thought it was an adequate place to set the preview surface. Reading the docs for
AndroidView
a bit further I found "TheĀ
update
Ā block can be run multiple times (on the UI thread as well) due to recomposition, and it is the right place to setĀ
View
Ā properties depending on state". Then I realized what was my mistake, and I moved everything to
factory
.
I guess the doc for
update
should be changed to something like
the callback to update the view when there is a recomposition
. Should I create a PR to update the docs?