flutter_confetti
flutter_confetti copied to clipboard
Svg support
https://github.com/funwithflutter/flutter_confetti/issues/46
Svg support with example. Particaly solved the issue above. (except png)
I made some refactoring with svg. It support Drawable interface and a user has possability to draw what he wants with this. There is an example with SVG. I think it's simple to make PNG drawing this way too.
Hey! Really like what you did. The Drawable interface is a smart idea and I get why we would want that to combine logic for all of the different drawing methods. The only thing is that it does add more complexity on the user's side. Where ideally that could be offloaded on to the package by just giving the path to an SVG or a PNG. Need to think about it a bit, but would like to keep the interface in the code, maybe just hide it from the user.
The bigger problem we have is with saveLayer
see here: https://flutter.dev/docs/perf/rendering/ui-performance#checking-for-non-cached-images
I also went down this route as the easiest way to add SVG and PNG support. This works when there are not that many confetti on screen, but too many calls to canvas.save()
will make the app unresponsive. For example, with the normal canvas drawing you can shoot hundreds, maybe thousands, of confetti per frame. While with this approach to save and transform the canvas we'd be limited to 20-50 per frame, before things slow down(depending on the device/platform). Also need to keep in mind that the example app has nothing else to paint and render. In an actual app these numbers would be a lot less.
Ideally for SVG support we need to actually read the path of the vectors, and modify them in a similar way to what the current path transform does. And avoid calls to saveLayer