Description
Currently Flutter has Picture.toImage
returning Future<Image>
(api docs). The API docs say "Although the image is returned synchronously, the picture is actually rasterized the first time the image is drawn and then cached". This makes me think that wrapping the result in a Future
is redundant. Can we have a Picture.toImageSync
that returns the image truly synchronously?
The use-case is procedurally generated atlasses that can be rendered using Canvas.drawAtlas
. For example, to render particle effects, such as those generated by https://felixblaschke.github.io/liquid-studio, it is more efficient to use an atlas rather than many drawCircle
s with blurring mask filter. However, to generate the atlas one needs to call Picture.toImage
and miss at least one frame. Picture.toImageSync
would allow us to generate an atlas synchronously (and cheaply, since the atlas contains just one particle) and in the same frame render thousands of particles using drawAtlas
.